忍不住敲个命令:
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

网友评论