MySQL 8.0 root账号权限恢复
1.MySQL配置文件添加一行: skip-grant-tables // 无密码访问
2.重启数据库
3.ssh登录数据库 mysql -uroot -p
4.切换数据库:use mysql
5.执行以下语句,更改root权限
update user set `Select_priv` = 'Y',`Insert_priv` = 'Y',`Update_priv` = 'Y',`Delete_priv` = 'Y',`Create_priv` = 'Y', `Drop_priv` = 'Y',`Reload_priv` = 'Y',`Shutdown_priv` = 'Y',`Process_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' and host='localhost';
6.exit 退出mysql命令行
7.删除配置文件中无密码验证配置航 skip-grant-tables
8.重启数据库
参考文案: