msyql8.0修改密码
- 修改配置文件:添加 skip-grant-tables
cd /etc/mysql/mysql.conf.d/
sudo vim mysqld.cnf
- 重启mysql服务。
sudo service mysql restart
- 登录mysql, 此时不需要密码
mysql -u root -p
- 进入mysql数据库
use mysql
- 将authentication_string 置空
update user set authentication_string='' where user='root';
- 设置新密码
alter user 'root'@'localhost' identified by 'newpassword'
- 异常 ERROR 1290 (HY000): The MySQL server is running with the --skip-grant-tables option so it cannot execute this statement 处理
FLUSH PRIVILEGES;
- 设置新密码
alter user 'root'@'localhost' identified by 'newpassword';
- 异常 ERROR 1524 (HY000): Plugin ‘auth_socket’ is not loaded
# 查看plugin
select user,plugin from mysql.user
# 设置为5.x版本密码认证方式
update user set plugin=‘mysql_native_password’ where user=‘root’;
FLUSH PRIVILEGES;
10 . 设置新密码
alter user 'root'@'localhost' identified by 'newpassword';
FLUSH PRIVILEGES;
-
将第一步的
skip-grant-tables注释掉; -
重启mysql服务