Linux服务器重置MYSQL密码

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/bcqd1211/article/details/85391343

在开发中,有时候会碰到mysql密码忘记的情况,这方面linux提供了比较便捷的重置密码方法
1.停掉mysql服务

sudo service mysql stop 

2.以安全模式启动MySQL:

sudo mysqld_safe --skip-grant-tables --skip-networking &  

3.接下来就可以无密码登录mysql了

mysql -u root

4.重设密码

mysql> use mysql;  
mysql> update user set password=PASSWORD("mynewpassword") where User='root';  
mysql> flush privileges; 

5.重启mysql服务

mysql > quit  
sudo service mysql restart  

猜你喜欢

转载自blog.csdn.net/bcqd1211/article/details/85391343
今日推荐