Question Réécriture:mysql créer la base de données et script utilisateur
HOMEDIR="ftpuser"
REMOTEIP="1.1.1.1"
MYSQLPASS="password"
Q1="DROP USER "$HOMEDIR"_shop;"
Q2="DROP DATABASE "$HOMEDIR"_shop;"
Q3="CREATE DATABASE IF NOT EXISTS "$HOMEDIR"_shop;"
Q4="GRANT ALL ON "$HOMEDIR"_shop TO '"$HOMEDIR"_shop'@'localhost' IDENTIFIED BY '$MYSQLPASS';"
Q5="GRANT ALL ON "$HOMEDIR"_shop TO '"$HOMEDIR"_shop'@'anotherip' IDENTIFIED BY '$MYSQLPASS';"
# Need to grant permissions from another server as well
Q6="FLUSH PRIVILEGES;"
SQL="${Q1}${Q2}${Q3}${Q4}${Q5}${Q6}"
echo $SQL
echo " "
ssh -p 8899 [email protected]$REMOTEIP "mysql -u root -p "$SQL""
Je lance alors:
/root/testing/migratesite.sh
et obtenez:
bash: DROP: command not found
bash: CREATE: command not found
bash: GRANT: command not found
bash: GRANT: command not found
bash: FLUSH: command not found
Qu'est-ce que je manque?
Works pour moi, MySQL 5.0.51, 3.2.39 BASH. L'exécutez-vous dans un autre script? Est-ce que cela fonctionne si vous l'exécutez via la ligne de commande? –
J'ai refait ma question pour expliquer exactement ce que je fais plutôt que ce sur quoi je me base! J'espère que cela pourra aider! – Lizard
Je dirais que ce 'ssh -p 8899 root @ $ REMOTEIP" mysql -u root -p $ SQL "" 'ne peut pas fonctionner à cause des guillemets ... mais je n'ai pas de machine pour l'essayer encore en cours ... essayer d'échapper les guillemets autour de $ SQL – Bobby