忘记密码要重置密码

cat /etc/mysql/debian.cnf

/etc/mysql/debian.cnf这个只有Debian或者Ubuntu服务器才有,里面有mysql安装后自带的用户,作用就是重启及运行mysql服务。我们用这个用户登录来达到重置密码的操作
在这里插入图片描述
使用上面的那个文件中的用户名和密码登录mysql
mysql -u[username] -p[password]
use mysql;
descibe table user; 主要是看密码列是authentication_string还是password
mysql5.7用这个:update user set authentication_string=password(‘newpassword’) where user=‘root’
mysql 8用这个:update user set authentication_string=‘newpassword’ where user=‘root’;
exit
重启mysql
systemctl restart mysql

修改密码

有一个mysqladmin命令
在这里插入图片描述
password选项就是用来修改密码的
那么修改密码就很简单了
mysqladmin -uroot -p password

重启mysql服务即可

Logo

魔乐社区(Modelers.cn) 是一个中立、公益的人工智能社区,提供人工智能工具、模型、数据的托管、展示与应用协同服务,为人工智能开发及爱好者搭建开放的学习交流平台。社区通过理事会方式运作,由全产业链共同建设、共同运营、共同享有,推动国产AI生态繁荣发展。

更多推荐