MySQL忘记密码怎么登录

MySQL忘记密码如何登录

  1. 编辑mysql的配置文件
vim /etc/my.cnf
....
'// 在文件的[mysqld]标签下添加一句:skip-grant-tables  '

然后保存退出。

  1. 重启数据库
systemctl restart mysqld
  1. 无密码登录mysql数据库
mysql -u root 
  1. 修改密码
mysql> use mysql;
mysql> update mysql.user set authentication_string=password('abc123') where user='root';    
'//  其中abc123为重新设置的密码,可以任意设置。'
  1. 把步骤1加的东西skip-grant-tables注释掉,然后重启服务器,就可以使用刚才修改的密码登录进服务器了。
 mysql -uroot -pabc123

猜你喜欢

转载自blog.csdn.net/qq_46480020/article/details/111940655