bug寶典之linux root使用者看不到mysql資料庫了
阿新 • • 發佈:2019-01-27
開啟一個ssh
service mysqld stop #關閉mysql
/usr/bin/mysqld_safe --skip-grant-tables & #安全模式
開啟另個ssh
mysql -u root -p
use mysql
select * from user where user='root' and host='localhost';#檢視到root使用者許可權都變成N了。
執行下面的語句
update user set `Select_priv` = 'Y' where user='root' and host='localhost';
update user set `Insert_priv` = 'Y' where user='root' and host='localhost';
update user set `Update_priv` = 'Y' where user='root' and host='localhost';
update user set `Delete_priv` = 'Y' where user='root' and host='localhost';
update user set `Create_priv` = 'Y' where user='root' and host='localhost' ;
update user set `Drop_priv` = 'Y' where user='root' and host='localhost';
update user set `Reload_priv` = 'Y' where user='root' and host='localhost';
update user set `Shutdown_priv` = 'Y' where user='root' and host='localhost';
update user set `Process_priv` = 'Y' where user='root' and host='localhost' ;
update user set `File_priv` = 'Y' where user='root' and host='localhost';
update user set `Grant_priv` = 'Y' where user='root' and host='localhost';
update user set `References_priv` = 'Y' where user='root' and host='localhost';
update user set `Index_priv` = 'Y' where user='root' and host='localhost';
update user set `Alter_priv` = 'Y' where user='root' and host='localhost';
update user set `Show_db_priv` = 'Y' where user='root' and host='localhost';
update user set `Super_priv` = 'Y' where user='root' and host='localhost';
update user set `Create_tmp_table_priv` = 'Y' where user='root' and host='localhost';
update user set `Lock_tables_priv` = 'Y' where user='root' and host='localhost';
update user set `Create_tmp_table_priv` = 'Y' where user='root' and host='localhost';
update user set `Lock_tables_priv` = 'Y' where user='root' and host='localhost';
update user set `Execute_priv` = 'Y' where user='root' and host='localhost';
update user set `Repl_slave_priv` = 'Y' where user='root' and host='localhost';
update user set `Repl_client_priv` = 'Y' where user='root' and host='localhost';
update user set `Create_view_priv` = 'Y' where user='root' and host='localhost';
update user set `Show_view_priv` = 'Y' where user='root' and host='localhost';
update user set `Create_routine_priv` = 'Y' where user='root' and host='localhost';
update user set `Alter_routine_priv` = 'Y' where user='root' and host='localhost';
update user set `Create_user_priv` = 'Y' where user='root' and host='localhost';
update user set `Event_priv` = 'Y' where user='root' and host='localhost';
update user set `Trigger_priv` = 'Y' where user='root' and host='localhost';
update user set `Create_tablespace_priv` = 'Y' where user='root' and host='localhost';
然後執行flush privileges;
,讓許可權生效,然後執行命令service mysqld start
啟動mysql即可