美文网首页
mysql 忘记root 密码

mysql 忘记root 密码

作者: 好想静静_2970 | 来源:发表于2017-11-22 11:52 被阅读0次

vim 打开/etc/my.cnf     根据实际情况 一般在ETC下面

在【mysqld】下面添加

skip-grant-tables

重启mysql服务

登陆mysql 

直接mysql 就进来了

然后 user mysql;

selecthost,user,passwordfrommysql.user;//即可查看到用户和密码

updateusersetpassword=password("newpasswd")whereuser="root";//'newpasswd'这里改为你要设置的密码

flushprivileges;

exit

最后把my.cnf 添加的那一段删除 重启数据库就OK了~

运维QQ交流群:171586999

相关文章

网友评论

      本文标题:mysql 忘记root 密码

      本文链接:https://www.haomeiwen.com/subject/hgynvxtx.html