【本人親測 已解決】044 - Access denied for user ‘root‘@‘%‘ to database ‘資料庫名稱‘

爱豆技术部發表於2024-06-12
mysql -u root -p
SELECT * FROM mysql.user;

use mysql; 
update user set Update_priv ='Y' where user = 'mushudb';
update user set Select_priv ='Y' where user = 'mushudb';
update user set Insert_priv ='Y' where user = 'mushudb';
update user set Update_priv ='Y' where user = 'mushudb';
update user set Delete_priv ='Y' where user = 'mushudb';
update user set Create_priv ='Y' where user = 'mushudb';
update user set Drop_priv ='Y' where user = 'mushudb';
update user set Reload_priv ='Y' where user = 'mushudb';
update user set Shutdown_priv ='Y' where user = 'mushudb';
update user set Process_priv ='Y' where user = 'mushudb';
update user set File_priv ='Y' where user = 'mushudb';
update user set Grant_priv ='Y' where user = 'mushudb';
update user set References_priv ='Y' where user = 'mushudb';
update user set Index_priv ='Y' where user = 'mushudb';
update user set Alter_priv ='Y' where user = 'mushudb';
update user set Show_db_priv ='Y' where user = 'mushudb';
update user set Super_priv ='Y' where user = 'mushudb';
update user set Create_tmp_table_priv ='Y' where user = 'mushudb';
update user set Lock_tables_priv ='Y' where user = 'mushudb';
update user set Execute_priv ='Y' where user = 'mushudb';
update user set Repl_slave_priv ='Y' where user = 'mushudb';
update user set Repl_client_priv ='Y' where user = 'mushudb';
update user set Create_view_priv ='Y' where user = 'mushudb';
update user set Show_view_priv ='Y' where user = 'mushudb';
update user set Create_routine_priv ='Y' where user = 'mushudb';
update user set Alter_routine_priv ='Y' where user = 'mushudb';
update user set Create_user_priv ='Y' where user = 'mushudb';
update user set Event_priv ='Y' where user = 'mushudb';
update user set Trigger_priv ='Y' where user = 'mushudb';
// 退出mysql
exit
// 重啟mysql服務
service mysqld restart

相關文章