mysql忘记密码后如何重置密码

macOS terminal
mysql 8.0

How to reset new password without old one

#1. stop mysql
/usr/local/mysql/support-files/mysql.server stop

#2.Run the server in safe mode with privilege bypass: 

sudo mysqld_safe --skip-grant-tables

#3.enter mysql
mysql -u root

#4.dont set password
> UPDATE mysql.user SET authentication_string=null WHERE User='root';

> FLUSH PRIVILEGES;

> \q


#set new password

mysql -u root

> ALTER USER 'root'@'localhost' IDENTIFIED BY '<new password>';

https://gist.github.com/zubaer-ahammed/c81c9a0e37adc1cb9a6cdc61c4190f52

Errors when resetting

I tried to launch it in safe mode, to which I received the following list of errors:

140131 00:03:02 mysqld_safe Logging to '/usr/local/var/mysql/david-mbp.err'.
140131 00:03:02 mysqld_safe Starting mysqld daemon with databases from /usr/local/var/mysql
140131 00:03:03 mysqld_safe mysqld from pid file /usr/local/var/mysql/david-mbp.pid ended

The issue is caused by file permission

#check file permission
ls -l /usr/local/mysql

# change permission
sudo chmod -R g+rwx /usr/local/var/mysql

https://stackoverflow.com/questions/21470193/mysql-server-start-issues-on-mavericks

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值