二进制安装MySQL 5.7.17 重置root密码

来源:互联网 发布:免费远程培训软件 编辑:程序博客网 时间:2024/06/05 19:24
  1. 拷贝support-files/my-default.cnf到/etc/my.cnf
  2. vim 编辑/etc/my.cnf,尾部追加一行

    skip-grant-tables
  3. 重启MySQL服务
  4. 进入MySQL,重置密码

    mysql -u root #进入MySQLupdate user set authentication_string=PASSWORD('newpass') where User='root'  #5.7.6以上update user set password=PASSWORD('newpass') where User='root'; #5.7.5 之前
  5. 退出,删除在/etc/my.cnf尾部追加的内容(skip-grant-tables),保存退出,重启MSYQL服务
  6. 进入MSYQL,使用新密码登录

    mysql -uroot  -pmysql> SET PASSWORD = PASSWORD('your_new_password');# 否则在创建数据库的时候会报如下错误

    ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.

PS:参考链接
https://www.skyf.org/reset-mysql579-root-password/
http://stackoverflow.com/questions/33467337/reset-mysql-root-password-using-alter-user-statement-after-install-on-mac

0 0
原创粉丝点击