广告
返回顶部
首页 > 资讯 > 数据库 >ERROR 1044 (42000): Access denied for user 'root'@'%' to database
  • 710
分享到

ERROR 1044 (42000): Access denied for user 'root'@'%' to database

2024-04-02 19:04:59 710人浏览 独家记忆
摘要

-- 2014.12.10         昨天根据开发的需要,创建了几个用户,但是在授权的时候报错: ERROR 1044 (42000): Acces

-- 2014.12.10

        昨天根据开发的需要,创建了几个用户,但是在授权的时候报错:
ERROR 1044 (42000): Access denied for user 'root'@'%' to database 'mdm'

在网上搜了一下,大概有以下几种说法:
1、对该数据库权限不足。
2、参数问题。
3、user的user列存在空值记录。
以上的解决方法基本上都是需要重启Mysql、而且都是片面的。

这里解释一下,出现这种情况的原因。
     首先这里是用root用户操作,所以对这个数据库的权限绝对是最高级的,但是如果是非root用户操作,就可能是权限的问题,需要root用户授权。
     出现上面的报错,很可能,其实应该可以说基本上都是因为my.cnf 文件里面有skip-name-resolve参数,这个参数导致这不能解析hostname或其它方式的登录, 所以登录任何用户,匹配的时候不走root@'localhost',或者127.0.0.1或者::1 ,而是 一个劲的走root@'%'.
再来查看一下每种方式下的root用户的具体权限:

  1. mysql> select * from user\\G;
  2. *************************** 1. row ***************************
  3.                   Host: bidevedw\\_db
  4.                   User: root
  5.               PassWord: *D013A4E3A5BB01E4239D18D7E93B59B7D2B767AD
  6.            Select_priv: Y
  7.            Insert_priv: Y
  8.            Update_priv: Y
  9.            Delete_priv: Y
  10.            Create_priv: Y
  11.              Drop_priv: Y
  12.            Reload_priv: Y
  13.          Shutdown_priv: Y
  14.           Process_priv: Y
  15.              File_priv: Y
  16.             Grant_priv: Y
  17.        References_priv: Y
  18.             Index_priv: Y
  19.             Alter_priv: Y
  20.           Show_db_priv: Y
  21.             Super_priv: Y
  22.  Create_tmp_table_priv: Y
  23.       Lock_tables_priv: Y
  24.           Execute_priv: Y
  25.        Repl_slave_priv: Y
  26.       Repl_client_priv: Y
  27.       Create_view_priv: Y
  28.         Show_view_priv: Y
  29.    Create_routine_priv: Y
  30.     Alter_routine_priv: Y
  31.       Create_user_priv: Y
  32.             Event_priv: Y
  33.           Trigger_priv: Y
  34. Create_tablespace_priv: Y
  35.               ssl_type:
  36.             ssl_cipher:
  37.            x509_issuer:
  38.           x509_subject:
  39.          max_questions: 0
  40.            max_updates: 0
  41.        max_connections: 0
  42.   max_user_connections: 0
  43.                 plugin:
  44.  authentication_string:
  45.       password_expired: N
  46. *************************** 2. row ***************************
  47.                   Host: ::1
  48.                   User: root
  49.               Password: *D013A4E3A5BB01E4239D18D7E93B59B7D2B767AD
  50.            Select_priv: Y
  51.            Insert_priv: Y
  52.            Update_priv: Y
  53.            Delete_priv: Y
  54.            Create_priv: Y
  55.              Drop_priv: Y
  56.            Reload_priv: Y
  57.          Shutdown_priv: Y
  58.           Process_priv: Y
  59.              File_priv: Y
  60.             Grant_priv: Y
  61.        References_priv: Y
  62.             Index_priv: Y
  63.             Alter_priv: Y
  64.           Show_db_priv: Y
  65.             Super_priv: Y
  66.  Create_tmp_table_priv: Y
  67.       Lock_tables_priv: Y
  68.           Execute_priv: Y
  69.        Repl_slave_priv: Y
  70.       Repl_client_priv: Y
  71.       Create_view_priv: Y
  72.         Show_view_priv: Y
  73.    Create_routine_priv: Y
  74.     Alter_routine_priv: Y
  75.       Create_user_priv: Y
  76.             Event_priv: Y
  77.           Trigger_priv: Y
  78. Create_tablespace_priv: Y
  79.               ssl_type:
  80.             ssl_cipher:
  81.            x509_issuer:
  82.           x509_subject:
  83.          max_questions: 0
  84.            max_updates: 0
  85.        max_connections: 0
  86.   max_user_connections: 0
  87.                 plugin:
  88.  authentication_string:
  89.       password_expired: N
  90. *************************** 3. row ***************************
  91.                   Host: %
  92.                   User: root
  93.               Password: *D013A4E3A5BB01E4239D18D7E93B59B7D2B767AD
  94.            Select_priv: Y
  95.            Insert_priv: Y
  96.            Update_priv: Y
  97.            Delete_priv: Y
  98.            Create_priv: Y
  99.              Drop_priv: Y
  100.            Reload_priv: Y
  101.          Shutdown_priv: Y
  102.           Process_priv: Y
  103.              File_priv: Y
  104.             Grant_priv: N
  105.        References_priv: Y
  106.             Index_priv: Y
  107.             Alter_priv: Y
  108.           Show_db_priv: Y
  109.             Super_priv: Y
  110.  Create_tmp_table_priv: Y
  111.       Lock_tables_priv: Y
  112.           Execute_priv: Y
  113.        Repl_slave_priv: Y
  114.       Repl_client_priv: Y
  115.       Create_view_priv: Y
  116.         Show_view_priv: Y
  117.    Create_routine_priv: Y
  118.     Alter_routine_priv: Y
  119.       Create_user_priv: Y
  120.             Event_priv: Y
  121.           Trigger_priv: Y
  122. Create_tablespace_priv: Y
  123.               ssl_type:
  124.             ssl_cipher:
  125.            x509_issuer:
  126.           x509_subject:
  127.          max_questions: 0
  128.            max_updates: 0
  129.        max_connections: 0
  130.   max_user_connections: 0
  131.                 plugin: mysql_native_password
  132.  authentication_string:
  133.       password_expired: N
  134. *************************** 4. row ***************************
  135.                   Host: %
  136.                   User: u_mdm_r2
  137.               Password: *CCB51F609423C18692BB961A7A83342B8311B6F4
  138.            Select_priv: N
  139.            Insert_priv: N
  140.            Update_priv: N
  141.            Delete_priv: N
  142.            Create_priv: N
  143.              Drop_priv: N
  144.            Reload_priv: N
  145.          Shutdown_priv: N
  146.           Process_priv: N
  147.              File_priv: N
  148.             Grant_priv: N
  149.        References_priv: N
  150.             Index_priv: N
  151.             Alter_priv: N
  152.           Show_db_priv: N
  153.             Super_priv: N
  154.  Create_tmp_table_priv: N
  155.       Lock_tables_priv: N
  156.           Execute_priv: N
  157.        Repl_slave_priv: N
  158.       Repl_client_priv: N
  159.       Create_view_priv: N
  160.         Show_view_priv: N
  161.    Create_routine_priv: N
  162.     Alter_routine_priv: N
  163.       Create_user_priv: N
  164.             Event_priv: N
  165.           Trigger_priv: N
  166. Create_tablespace_priv: N
  167.               ssl_type:
  168.             ssl_cipher:
  169.            x509_issuer:
  170.           x509_subject:
  171.          max_questions: 0
  172.            max_updates: 0
  173.        max_connections: 0
  174.   max_user_connections: 0
  175.                 plugin: mysql_native_password
  176.  authentication_string:
  177.       password_expired: N
  178. ERROR:
  179. No query specified

  180. mysql>
您可能感兴趣的文档:

--结束END--

本文标题: ERROR 1044 (42000): Access denied for user 'root'@'%' to database

本文链接: https://www.lsjlt.com/news/48826.html(转载时请注明来源链接)

有问题或投稿请发送至: 邮箱/279061341@qq.com    QQ/279061341

本篇文章演示代码以及资料文档资料下载

下载Word文档到电脑,方便收藏和打印~

下载Word文档
猜你喜欢
软考高级职称资格查询
编程网,编程工程师的家园,是目前国内优秀的开源技术社区之一,形成了由开源软件库、代码分享、资讯、协作翻译、讨论区和博客等几大频道内容,为IT开发者提供了一个发现、使用、并交流开源技术的平台。
  • 官方手机版

  • 微信公众号

  • 商务合作