MySQL新建表:1044 - Access denied for user ‘root‘@%‘ to database ‘ ...

打印 上一主题 下一主题

主题 861|帖子 861|积分 2583

1.题目形貌

环境一: Navicat连接远程mysql数据库,创建数据库时出现错误:

环境二: 在linux中下令创建数据库出现如下报错:

2.原因分析

root权限不够,先利用“SELECT host,user,Grant_priv,Super_priv FROM mysql.user;”查询,发现已经是Y了。

通过SELECT * FROM mysql.user;下令查询权限信息,可以看到root对应的很多权限都是N,如下图所示:

至于为什么会出现root权限不够,大概是安装mysql的时间MySQL权限配置不精确,或者修改了干系的配置文件等。
3.办理方案

将root权限全部修改为Y,执行如下代码(记得退出mysql,重启服务):
修改权限
  1. use mysql;
  2. update user set Update_priv ='Y' where user = 'root';
  3. update user set Select_priv ='Y' where user = 'root';
  4. update user set Insert_priv ='Y' where user = 'root';
  5. update user set Update_priv ='Y' where user = 'root';
  6. update user set Delete_priv ='Y' where user = 'root';
  7. update user set Create_priv ='Y' where user = 'root';
  8. update user set Drop_priv ='Y' where user = 'root';
  9. update user set Reload_priv ='Y' where user = 'root';
  10. update user set Shutdown_priv ='Y' where user = 'root';
  11. update user set Process_priv ='Y' where user = 'root';
  12. update user set File_priv ='Y' where user = 'root';
  13. update user set Grant_priv ='Y' where user = 'root';
  14. update user set References_priv ='Y' where user = 'root';
  15. update user set Index_priv ='Y' where user = 'root';
  16. update user set Alter_priv ='Y' where user = 'root';
  17. update user set Show_db_priv ='Y' where user = 'root';
  18. update user set Super_priv ='Y' where user = 'root';
  19. update user set Create_tmp_table_priv ='Y' where user = 'root';
  20. update user set Lock_tables_priv ='Y' where user = 'root';
  21. update user set Execute_priv ='Y' where user = 'root';
  22. update user set Repl_slave_priv ='Y' where user = 'root';
  23. update user set Repl_client_priv ='Y' where user = 'root';
  24. update user set Create_view_priv ='Y' where user = 'root';
  25. update user set Show_view_priv ='Y' where user = 'root';
  26. update user set Create_routine_priv ='Y' where user = 'root';
  27. update user set Alter_routine_priv ='Y' where user = 'root';
  28. update user set Create_user_priv ='Y' where user = 'root';
  29. update user set Event_priv ='Y' where user = 'root';
  30. update user set Trigger_priv ='Y' where user = 'root';
复制代码
退出mysql
  1. exit
复制代码
重启mysql服务
  1. service mysqld restart
复制代码
如图所示:修改成功

4.验证

已经可以创建表了
参考帖子:https://tencentcloud.csdn.net/64e5cfb5a3cccc782cc56451.html

免责声明:如果侵犯了您的权益,请联系站长,我们会及时删除侵权内容,谢谢合作!更多信息从访问主页:qidao123.com:ToB企服之家,中国第一个企服评测及商务社交产业平台。

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?立即注册

x
回复

使用道具 举报

0 个回复

倒序浏览

快速回复

您需要登录后才可以回帖 登录 or 立即注册

本版积分规则

郭卫东

金牌会员
这个人很懒什么都没写!

标签云

快速回复 返回顶部 返回列表