CentOS修改MySQL忘记root密码
全文约 169 字预计阅读 1 分钟
找到MySQL配置文件/etc/my.cnf,找一行加入以下内容跳过表的授权
skip-grant-tables执行/etc/init.d/mysqld restart或service mysqld restart重启mysql root用户登录直接MySQL,提示密码直接回车
mysql -uroot -p有密码提示也忽略,回车即可。 然后执行修改密的命令和刷新纪录。 mysql5.7执行修改密码语句是
update mysql.user set authentication_string=password('新密码') where user='root';
MySQL是5.7以下,则修改密码的语句是
update mysql.user set password=password('新密码') where user='root';
flush privileges;//刷库接下来去掉配置文件里面刚才添加的参数,再重启mysql就可以了。
CentOS修改MySQL忘记root密码
评论 0 条
暂无评论,来说点什么吧。