MySQL8报错:Access denied for user ‘root‘@‘%‘ to database ‘myTest‘
2023-12-17 16:29:42
今天突然遇到一个来自Mysql8的报错:Access denied for user 'root'@'%' to database 'myTest',就是可以通过远程链接数据库,但是无法创建,修改,删除等等数据库操作,很奇怪. 于是我看了很多的博客, 有的博客说:GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' WITH GRANT OPTION; 有的说:GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '你的密码' WITH GRANT OPTION; 但是都解决不了问题: 于是细想,这个问题不正是因为root用户突然失去了数据库操控的权限嘛,我们可以把权限都设置为Y:
update user set Select_priv ='Y' where user = 'root';
update user set Insert_priv ='Y' where user = 'root';
update user set Update_priv ='Y' where user = 'root';
update user set Delete_priv ='Y' where user = 'root';
update user set Create_priv ='Y' where user = 'root';
update user set Drop_priv ='Y' where user = 'root';
update user set Reload_priv ='Y' where user = 'root';
update user set Shutdown_priv ='Y' where user = 'root';
update user set Process_priv ='Y' where user = 'root';
update user set File_priv ='Y' where user = 'root';
update user set Grant_priv ='Y' where user = 'root';
update user set References_priv ='Y' where user = 'root';
update user set Index_priv ='Y' where user = 'root';
update user set Alter_priv ='Y' where user = 'root';
update user set Show_db_priv ='Y' where user = 'root';
update user set Super_priv ='Y' where user = 'root';
update user set Create_tmp_table_priv ='Y' where user = 'root';
update user set Lock_tables_priv ='Y' where user = 'root';
update user set Execute_priv ='Y' where user = 'root';
然后再刷新重启MySQL:
flush privileges;
service mysql restart
终于恢复正常了。。。遂记录下解决的过程。
文章来源:https://blog.csdn.net/m0_54409739/article/details/135043773
本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。 如若内容造成侵权/违法违规/事实不符,请联系我的编程经验分享网邮箱:veading@qq.com进行投诉反馈,一经查实,立即删除!
本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。 如若内容造成侵权/违法违规/事实不符,请联系我的编程经验分享网邮箱:veading@qq.com进行投诉反馈,一经查实,立即删除!