我嘗試使用shell腳本如下修改MySQL的root用戶密碼shell腳本
#!/bin/bash
mysql.server start
mysql -u root << EOF
SET PASSWORD FOR [email protected]'localhost' = PASSWORD(‘admin’);
EOF
更改用戶密碼,但我得到以下錯誤: -
ERROR 1064 (42000) at line 1: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '‘admin’)' at line 1
不是set密碼時應的命令,如果用別的東西會像如果我使用「創建數據庫數據庫名稱」將會作品。
。
Update1:
如果我使用「管理員」或「管理員」而不是「管理員」,我得到了以下錯誤。
ERROR 1064 (42000) at line 1: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '「admin2」)' at line 1
。
Update2:
當使用-e標誌我有以下錯誤
./mysql.sh: line 3: syntax error near unexpected token
(' ./mysql.sh: line 3:
mysql -u root -padmin -e 「SET PASSWORD FOR [email protected]'localhost' = PASSWORD(‘admin2’);」'
'「admin''你能在這些報價包裝?嘗試'「管理員」'或''admin''代替 – Gravy
感謝回答,我認爲問題是由於編輯:) –