• 周日. 6月 26th, 2022

5G编程聚合网

5G时代下一个聚合的编程学习网

热门标签

MySQL 5.7.x修改root默认密码

admin

11月 28, 2021

1.编辑my.cnf文件加入skip-grant-tables,忽略密码登录

[[email protected] ~]# vi /etc/my.cnf

[mysqld]

skip-grant-tables

[[email protected] ~]# sudo service mysql restart

2.修改密码

[[email protected] ~]# mysql
mysql> update mysql.user set authentication_string=PASSWORD(‘root1234′) where user=’root’ and host=’localhost’;
mysql> flush privileges;
mysql> exit;

3.开启密码登录

[[email protected] ~]# vi /etc/my.cnf

[mysqld]

#skip-grant-tables

[[email protected] ~]# sudo service mysql restart

4.修复错误

[[email protected] ~]# mysql -uroot -proot1234;

[[email protected] ~]# mysql> show databases;

ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.

mysql> ALTER USER ‘root’@’localhost’ IDENTIFIED BY ‘root1234’

Query OK, 0 rows affected (0.09 sec)

一个勤劳的搬砖程序员

发表评论

您的电子邮箱地址不会被公开。