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

  1. 拷贝support-files/my-default.cnf到/etc/my.cnf
  2. vim 编辑/etc/my.cnf,尾部追加一行

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

    mysql -u root #进入MySQL
    update 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  -p
    mysql> 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

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值