首页 > 数据库 > MySQL > Mysql root密码忘记找回妙招
一、Mysql root用户密码忘记(8.0以下版本)
二、Mysql root用户密码忘记(8.0及以上版本)
G:\mysql-8.0.23-winx64\bin\mysqld --datadir=G:\mysql-8.0.23-winx64\data80323308 --console --skip-grant-tables --shared-memory
mysql> select user,host,authentication_string from mysql.user;
mysql> delete from mysql.user where user='root' ;
mysql> flush privileges; --记得刷新哈,如果提示无法创建
mysql> create user root@'%' identified with mysql_native_password by 'root';
mysql> grant all on *.* to root@'%' with grant option;
mysql> flush privileges;
mysql> drop user 'root'@'localhost';
mysql> flush privileges;
mysql> create user root@'localhost' identified with mysql_native_password by 'root';
mysql> grant all on *.* to root@'localhost' with grant option;
mysql> flush privileges;
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/69947868/viewspace-2768479/ ,如需转载,请注明出处,否则将追究法律责任。