ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)
1,编辑my.cnf vi /etc/my.cnf
在[mysqld]的段中加上一句skip-grant-tables
[mysqld]
skip-grant-tables
2,重新启动 mysql
systemctl start mysqld
3,登录 mysql
mysql -uroot -p
Enter password:
一直敲回车
4,修改 mysql 的密码
use mysql;
update user set authentication_string = '' where user = 'root';
authentication_string = ’ ’ 把root密码设置为空;
5,再次打开 my.cnf 配置文件
把刚刚添加内容删除
[mysqld]
skip-grant-tables
6,重启 mysql 服务
service mysql restart
7,进入 mysql 修改密码
mysql -uroot -p
8,修改密码
ALTER USER USER() IDENTIFIED BY '123456';