mysql忘记密码
不知道为啥,我用apt-get install 安装mysql,安装直接完成,不会提示输入密码.
搞得装完数据库就得进入忘记密码模式/(ㄒoㄒ)/~~
之前老是百度,累了,征得大佬同意,放一篇转载.
mysql忘记密码踩坑记
关键步骤:
1.进入/etc/mysql/目录,并用root权限打开debian.cnf文件
2.复制账号密码备用([client]下的user 和 password)
[client]
host = localhost
user = debian-sys-maint
password = ExL3iUl2zfI5K8p7x
3.使用这个账号密码登入mysql
4.use mysql;
5.查看数据库表结构:desc user;
6. select user,plugin from user;
7.一般来说,authentication_string 字段存储的就是密码,修改 authentication_string 的值即可.但是若结果如上图所示,则增加一句
update user set authentication_string=password("123456"),plugin='mysql_native_password' where user='root';
update mysql.user set authentication_string=password('123456') where user='root';
flush privileges; //刷新重置
quit //退出
8.重启数据库:
service mysql restart
mysql -u root -p // 输入密码,登陆成功
搞定.
来源:CSDN
作者:发际线稳不住的伤
链接:https://blog.csdn.net/jzl1123/article/details/104214578