Mysql8在Mac上忘记密码
- 1.关闭mysql服务器
sudo /usr/local/mysql/support-files/mysql.server stop
- 2.进入目录
cd /usr/local/mysql/bin
- 3.获取权限
cd /usr/local/mysql/bin
- 4.重启服务器
./mysqld_safe --skip-grant-tables &
-
5.control + D退出编辑
-
6.配置短命令
alias mysql=/usr/local/mysql/bin/mysql
- 7.进入mysql命令模式
mysql
- 8.进入mysql数据库
use mysql
- 9.获取更改权限
flush privileges;
- 10
UPDATE user SET authentication_string = '' WHERE User = 'root';
- 11.退出
exit
- 12.无需密码进入mysql命令模式
mysql -uroot -p
- 13.进入mysql数据库
use mysql
- 14.修改密码
ALTER user 'root'@'localhost' IDENTIFIED BY '123456';