参考:Mysql 8.0.13忘记密码 重置密码
做了如下操作:
select host, user, pligin from user; 查看了系统mysql库-user表的加密规则,默认为:update user set plugin='mysql_native_password'; FLUSH PRIVILEGES; 修改了所有的规则为mysql_native_password,并刷新MySQL的系统权限相关表,GRANT ALL PRIVILEGES ON *.* TO 'root'@'%'WITH GRANT OPTION; 开放权限同事仍连不上我的库,显示我这边不允许连接,怀疑是我本地没开远程权限,重启了mysql。出现问题:Host 'localhost' is not allowed to connect to this MySQL server ,我自己都连不上本地的mysql。参考:ubuntu下MySQL忘记密码重置方法
vim /etc/mysql/mysql.conf.d/mysqld.cnf
add new line skip-grant-tables
service mysql restart
enter mysql in terminal mysql
change to mysql use mysql;
modify pswd update user set authentication_string='' where user='root';
可通过 select user, host from mysql.user; 查询 user和host,便于精准修改。update user set authentication_string='' where user='root' and host='%';quit;vim /etc/mysql/mysql.conf.d/mysqld.cnf
注释掉 skip-grant-tables
重启mysql服务 service mysql restart
mysql > use mysql修改新密码, ALTER USER 'root'@'localhost' IDENTIFIED WITH caching_sha2_password BY '000000';
可通过 select user, host from mysql.user; 查询 user和host,便于精准修改。ALTER USER 'root'@'%' IDENTIFIED WITH caching_sha2_password BY '000000';quit;bingo bingo。。。