当前位置:Gxlcms > 数据库问题 > 忘记MySQL密码,如何破?

忘记MySQL密码,如何破?

时间:2021-07-01 10:21:17 帮助过:4人阅读

1.单实例

现将数据库停掉

/etc/init.d/mysqld stop

使用如下命令登陆

mysqld_safe --skip-grant-tables --user=mysql &

现在可以使用mysql登陆了

mysql -uroot

然后就可以改密码了

update mysql.user set password=password("password") where user=‘root‘ and host=‘localhost‘;


2.多实例

先将数据库停掉,然后使用如下命令启动数据库

/bin/sh /application/mysql/bin/mysqld_safe --defaults-file=my.cnf --skip-grant-tables --user=mysql &

登陆

mysql -uroot -S mysql.sock

然后就可以改密码了

update mysql.user set password=password("password") where user=‘root‘ and host=‘localhost‘;

本文出自 “老暖男的博客” 博客,请务必保留此出处http://ashine.blog.51cto.com/1632639/1654058

忘记MySQL密码,如何破?

标签:mysql

人气教程排行