忘记mysql的密码

mysql版本 8.0.15
修改配置文件
vim /etc/my.cnf

	[mysqld]
	skip-grant-tables      #设置启动忽略密码

进入mysql
alter user ‘root’@‘localhost’ identified by ‘密码’; (8.0.15修改密码,密码必须符合mysql的规则)
update mysql.user set authentication_string=password1(‘root’) where user=‘root’; (mysql8.0.15版本已经不支持了)
修改完密码后再修改配置文件,注释或删掉启动忽略密码的配置

猜你喜欢

转载自blog.csdn.net/qq_39170130/article/details/87938967