Linux上数据库密码忘记

因为虚拟机太久不用了,忘记了当初设置的数据库密码。
vi /etc/my.cnf 在[mysqld]添加
skip-grant-tables

重启数据库服务

systemctl restart mysql

登录到数据库 mysql -u root pxxxxx

update mysql.user set password=PASSWORD(“54wanglas”) where user=”root”;
flush privileges;
这样就设置完了密码,再次重启mysql服务。
It’s work

ps:别忘了删掉skip-grant-tables

猜你喜欢

转载自blog.csdn.net/weixin_38576764/article/details/80062239
今日推荐