美文网首页
MYSQL8.0以上版本ROOT密码报错及修改

MYSQL8.0以上版本ROOT密码报错及修改

作者: RainySpring | 来源:发表于2020-08-05 17:25 被阅读0次

忍不住敲个命令:
service mysqld stop 很奇怪为什么mysql后面要加d
service musqld restart

alter user 'root'@'localhost' identified by '新的密码';
alter user 'root'@'%' identified by '新的密码;
这里记录下,今天遇到的问题:
重新修改mysql密码的时候,根据网上步骤,将localhost 改为 ‘%’,就可以执行不报错了,但是我这里依然报:

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 '%' at line 1

寻找大量文章后发现,我们需要先置空之前的密码:
update user set authentication_string='' where user='root';
也有可能是因为我之前设置authentication_string 没有加password加密函数导致的。之后操作上面密码修改命令就可以了。

注:
如果忘记密码 可以修改 /etc/my.cnf配置文件添加忽略校验命令,这样 mysql -uroot -p就不需要校验密码了 ,直接回车就行

skip-grant-tables

image.png

相关文章

网友评论

      本文标题:MYSQL8.0以上版本ROOT密码报错及修改

      本文链接:https://www.haomeiwen.com/subject/grjprktx.html