ubuntu系统mysql忘记登录密码

1.ubuntu中mysql安装时会将初始密码存放在/etc/mysql/debian.cnf 文件中
查找该文件sudo find / -name debian.cnf
2.打开debian.cnf
sudo vim debian.cnf
在这里插入图片描述3.使用user和password登录后,修改mysql数据库中user数据表的用户登录密码
user是用户名,authentication_string就是密码

update user set authentication_string=password('123456') where user='root';

4.重启mysql
service mysql restart
就可以使用刚才设置的用户名和密码登录mysql了

猜你喜欢

转载自blog.csdn.net/chailihua0826/article/details/88795652