99.FAQ
# 01.root登录没有权限
- 修改用户权限全为Y
UPDATE user SET select_priv='Y',Insert_priv='Y',Update_priv='Y',Delete_priv='Y',Create_priv='Y',Drop_priv='Y',Reload_priv='Y',File_priv='Y',Grant_priv='Y',References_priv='Y',Index_priv='Y',Alter_priv='Y',Show_db_priv='Y',Super_priv='Y',Create_tmp_table_priv='Y',Lock_tables_priv='Y',Execute_priv='Y',Repl_slave_priv='Y',Repl_client_priv='Y',Create_view_priv='Y',Show_view_priv='Y',Create_routine_priv='Y',Alter_routine_priv='Y',Create_user_priv='Y',Event_priv='Y',Trigger_priv='Y',Create_tablespace_priv='Y' WHERE user='root';
1
- 刷新权限
MySQL> flush privileges; # 刷新权限
MySQL> quit # 退出
systemctl restart MySQL # 重启服务
1
2
3
2
3
# 02.MySQL 忘记密码
- 1、关闭MySQL服务
# 老版本
sudo /usr/local/MySQL/support-files/MySQL.server stop
# mac新版本
sudo /usr/local/bin/MySQL.server stop
1
2
3
4
2
3
4
- 2、进入MySQL各种执行文件的 目录
# 新版本:
cd /usr/local/MySQL/bin
# 老版本:
cd /usr/local/bin
1
2
3
4
2
3
4
- 4、重启服务器
sudo ./MySQLd_safe --skip-grant-tables & # 输入mac 电脑密码
1
- 5、重开个终端
# 执行然后会提示输入密码,回车就行
MySQL -u root -p
1
2
2
- 6、获取权限
flush privileges;
1
- 7、设置新密码
ALTER USER ‘root’@‘localhost’ IDENTIFIED WITH caching_sha2_password BY '123456';
1
上次更新: 2024/10/15 16:27:13