ERROR 1064 (42000)MySQL中使用mysqladmin或set修改root密码时提示语法错误

Posted LaplaceKang

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了ERROR 1064 (42000)MySQL中使用mysqladmin或set修改root密码时提示语法错误相关的知识,希望对你有一定的参考价值。

报错信息:

mysql> mysqladmin -uroot -p123456 password 654321;
ERROR 1064 (42000): 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 ‘mysqladmin -uroot -p123456 password 654321‘ at line 1

mysql> set password for root@localhost = password(‘654321‘);
ERROR 1064 (42000): 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 ‘password(‘654321‘)‘ at line 1

报错原因:

新版本MySQL(8.0以上)不支持使用mysqladmin -uroot -p123456 password 654321;“set password for root@localhost = password(‘654321‘);”来修改密码。

解决方法:

  • alter user‘root‘@‘localhost‘ identified by ‘新密码‘;
  • alter user‘root‘@‘localhost‘ identified with mysql_native_password by ‘新密码‘;

以上是关于ERROR 1064 (42000)MySQL中使用mysqladmin或set修改root密码时提示语法错误的主要内容,如果未能解决你的问题,请参考以下文章

UDF 触发器不起作用 MySQL ERROR 1064 (42000)

MySQL ERROR 1064 (42000)——不管怎样grant总是报错,怎么回事?

ERROR 1064 (42000)MySQL中使用mysqladmin或set修改root密码时提示语法错误

解决mysql 8报错 ERROR 1064 (42000): You have an error in your SQL syntax

解决mysql 8报错 ERROR 1064 (42000): You have an error in your SQL syntax

MySQL:错误 1142 (42000) 和错误 1064 (42000)