問改寫:的MySQL創建數據庫和用戶腳本
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""
我然後運行:
/root/testing/migratesite.sh
並獲得:
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
我缺少什麼?
對我的作品中,MySQL 5.0.51,BASH 3.2.39。你是否在另一個腳本中運行它?如果通過命令行運行它,它會運行嗎? – 2009-11-03 11:55:42
我已經重做我的問題來解釋我正在做什麼,而不是我基於它的東西!希望有所幫助! – Lizard 2009-11-03 12:04:45
我會說這個'ssh -p 8899 root @ $ REMOTEIP「mysql -u root -p $ SQL」「'因爲引號而無法工作......但是我沒有機器去試試它出來還有...試圖繞過$ SQL的引號 – Bobby 2009-11-03 12:09:13