2016-04-28 44 views
1

這段代碼是從學習MySQL和MariaDB的書:MySQL的:試圖爲root設置一個密碼,錯誤SQL語法

mysql -u root -p -e "SET PASSWORD FOR 'root'@'127.0.0.1' PASSWORD('new_pwd');" 

而且我得到這個錯誤:

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 th 
e right syntax to use near 'PASSWORD('new_pwd')' at line 1 

這本書是否正確?這個語法不是舊的嗎?有什麼問題?

回答

2

嘗試:

mysql -u root -p -e "SET PASSWORD FOR 'root'@'127.0.0.1' = PASSWORD('new_pwd');" 
+1

謝謝!現在它工作正常。 – 9Algorithm

+0

很酷。我很高興它的工作。另外,請接受我的答案作爲解決方案:) –