macOS Ventura13.0.1使用 brewhome 安装mysql8.0.32,安装好之后是没有密码的,需要进入mysql进行密码修改,这是固定步骤了。但是这次安装之后,进去按照之前的修改方法,竟然报语法错误。。。。(已经修改密码策略!!!)
如下:
ALTER USER ‘root’@‘localhost’ IDENTIFIED BY ‘123123’;
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 '‘123123’' at line 1
update user set authentication_string=password('123123') where user='root';
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 '('123123') where user='root'' at line 1
按道理就是这样的方式啊。。。
查了好久,在stack overflow上找到了外国友人的解决方法,是因为不知道啥时候 password()不能用了(mysql5.7版本还是要按上面的方式改),需要改成caching_sha2_password。如下:
mysql -u root --在安装好第一次进入是不需要密码的
--修改密码策略(就是密码的安全等级,修改的低一点)
set global validate_password.length = 6;
set global validate_password.policy = 0;
--按照下面的语句修改密码即可
ALTER USER 'root'@'localhost' IDENTIFIED WITH caching_sha2_password BY '123123';

被折叠的 条评论
为什么被折叠?



