ubuntu 忘记mysql 密码解决方法
一段时间没有用mysql数据库,今天突然需要使用,结果忘记密码,google了下找到的解决方法,就顺便记录下,下次碰到就不需要这么麻烦了
1、输入命令 cat /etc/mysql/debian.cnf

ubuntu 忘记mysql 密码解决方法-亲测有效

2、使用账号 debian-sys-maint 账号登录mysql密码为 debian.cnf 中password 值(# password 值每个人的情况不一样,根据实际情况),在切换到mysql
ubuntu 忘记mysql 密码解决方法-亲测有效

3、修改root账号密码(自己方便修改为123456了)
update mysql.user set authentication_string=password(‘123456’) where user=‘root’ and Host=‘localhost’;
update user set plugin=‘mysql_native_password’;
flush privileges;

ubuntu 忘记mysql 密码解决方法-亲测有效

4、修改密码后登录
mysql -u root -p

ubuntu 忘记mysql 密码解决方法-亲测有效

转发自 https://www.cnblogs.com/ioan/p/10614623.html

相关文章: