MySQL:尝试为root设置密码,在SQL语法中设置错误

时间:2016-04-28 18:33:49

标签: mysql

这段代码来自学习MySQL和MariaDB 一书:

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

这本书是否正确?这种语法不老吗?有什么问题?

1 个答案:

答案 0 :(得分:2)

尝试:

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