ITPub博客

首页 > 数据库 > MySQL > MySQL 5.7修改忘记root密码

MySQL 5.7修改忘记root密码

原创 MySQL 作者:wolfreturn 时间:2016-02-29 16:38:56 0 删除 编辑
MySQL 5.7 mysql库的user表中已经不再有password字段,取而代之的为authentication_string
修改语法相同,步骤也相同。
注意:
/etc/my.cnf这个配置文件中,
basedir、datadir这两个参数的指向,如果指向错误,mysqld_safe --skip-grant-tables启动没有mysql库。

[mysql@guoqing ~]$ service mysqld stop    #停止mysql服务


[mysql@guoqing ~]$ mysqld_safe --skip-grant-tables &  #以不启用grant-tables模式启动mysql


[mysql@guoqing ~]$ mysql -uroot -p -h127.0.0.1 #输入命令回车进入,出现输入密码提示直接回车。


mysql>update mysql.user set authentication_string= password ('guo') WHERE User='root'; #更改密码为 guo


mysql>flush privileges; #更新权限
mysql>quit #退出
service mysql start
重新登录即可使用新密码。

来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/24742969/viewspace-2016482/ ,如需转载,请注明出处,否则将追究法律责任。

上一篇: MySQL unsigned属性
请登录后发表评论 登录
全部评论
数据库维修工。 http://idber.github.io

注册时间:2014-07-11

  • 博文量
    58
  • 访问量
    681955