标签:免密码 sql roo options com use word 添加 update
经常会有朋友或者同事问起,MySQL 的 root 密码忘了,不知道改怎么办。
其实解决方法很简单,下面是详细的操作步骤。
skip-grant-tables,重启MySQL服务即可免密码登录
# SERVER SECTION # ---------------------------------------------------------------------- # # The following options will be read by the MySQL Server. Make sure that # you have installed the server correctly (see above) so it reads this # file. # [mysqld] skip-grant-tables
[root@localhost mysql]# mysql -uroot Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 53 Server version: 5.0.41-community-log MySQL Community Edition (GPL) Type ‘help;‘ or ‘\h‘ for help. Type ‘\c‘ to clear the buffer. mysql> mysql> ALTER USER ‘root‘@‘localhost‘ IDENTIFIED WITH mysql_native_password BY ‘123‘;
ERROR 1290 (HY000): The MySQL server is running with the --skip-grant-tables option so it cannot execute this statement
mysql> update user set authentication_string = NULL where user = ‘root‘;
Query OK, 1 row affected (0.00 sec)
上面是先用grant的方式修改root密码,但是由于使用了配置了skip-grant-tables 选项,使用“alter user”命令更改密码失败,直
接更新 user 表的 authentication_string字段后更改密码成功。
mysql> ALTER USER ‘root‘@‘localhost‘ IDENTIFIED WITH mysql_native_password BY ‘123‘;
标签:免密码 sql roo options com use word 添加 update
原文地址:https://www.cnblogs.com/ryanzheng/p/9348723.html