中文字幕av专区_日韩电影在线播放_精品国产精品久久一区免费式_av在线免费观看网站

溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務條款》

Mysql連接錯誤ERROR 1045 (28000): Access denied for user問題的解決方法

發布時間:2021-09-16 16:36:24 來源:億速云 閱讀:673 作者:chen 欄目:MySQL數據庫

本篇內容主要講解“Mysql連接錯誤ERROR 1045 (28000): Access denied for user問題的解決方法”,感興趣的朋友不妨來看看。本文介紹的方法操作簡單快捷,實用性強。下面就讓小編來帶大家學習“Mysql連接錯誤ERROR 1045 (28000): Access denied for user問題的解決方法”吧!

  1. 從192.168.111.99上連接遠程數據的時候報錯:


  2. [mysql@LVS01 mysql_5621]$ mysql -uroot -p123 -h292.168.111.10 -P 5621

  3. Warning: Using a password on the command line interface can be insecure.

  4. ERROR 1045 (28000): Access denied for user 'root'@'192.168.111.99' (using password: YES



  5. 查看遠程主機權限:


  6. mysql> use mysql;

  7. Database changed

  8. mysql> select user,host,password from user;

  9. +-------+----------------+-------------------------------------------+

  10. | user | host | password |

  11. +-------+----------------+-------------------------------------------+

  12. | root | localhost | *23AE809DDACAF96AF0FD78ED04B6A265E05AA257 |

  13. | root | mysql-svr1 | |

  14. | root | 127.0.0.1 | |

  15. | root | ::1 | |

  16. | repl | 192.168.110.20 | *A424E797037BF97C19A2E88CF7891C5C2038C039 |

  17. | repl | 192.168.111.20 | *A424E797037BF97C19A2E88CF7891C5C2038C039 |

  18. | repl | 192.168.111.30 | *A424E797037BF97C19A2E88CF7891C5C2038C039 |

  19. | repl | 192.168.111.10 | *A424E797037BF97C19A2E88CF7891C5C2038C039 |

  20. | user1 | % | *23AE809DDACAF96AF0FD78ED04B6A265E05AA257 |

  21. | root | 192.168.111.20 | *23AE809DDACAF96AF0FD78ED04B6A265E05AA257 |

  22. | root | 192.168.111.30 | *23AE809DDACAF96AF0FD78ED04B6A265E05AA257 |

  23. | root | 192.168.111.10 | *23AE809DDACAF96AF0FD78ED04B6A265E05AA257 |

  24. | admin | 192.168.111.10 | *4ACFE3202A5FF5CF467898FC58AAB1D615029441 |

  25. | root | 192.168.111.% | |

  26. | root | 192.168.111.99 | |

  27. | root | % | *23AE809DDACAF96AF0FD78ED04B6A265E05AA257 |

  28. +-------+----------------+-------------------------------------------+

  29. 16 rows in set (0.00 sec)


  30. 發現已經給192.168.111.99授權了,可為什么還是連不上?


  31. 和192.168.111.99相關的權限是下面幾行:



  32. | root | 192.168.111.% | |

  33. | root | 192.168.111.99 | |

  34. | root | % | *23AE809DDACAF96AF0FD78ED04B6A265E05AA257 |


  35. 嘗試使用空密碼登陸成功:


  36. [mysql@LVS01 mysql_5621]$ mysql -uroot -h292.168.111.10 -P 5621

  37. Welcome to the MySQL monitor. Commands end with ; or \g.

  38. Your MySQL connection id is 20216

  39. Server version: 5.6.21-log Source distribution

  40. Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved.

  41. Oracle is a registered trademark of Oracle Corporation and/or its

  42. affiliates. Other names may be trademarks of their respective

  43. owners.

  44. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

  45. mysql>


  46. 刪除密碼為空的用戶:


  47. mysql> drop user root@'192.168.111.%';

  48. Query OK, 0 rows affected (0.31 sec)

  49. mysql> drop user root@'192.168.111.99';

  50. Query OK, 0 rows affected (0.00 sec)


  51. mysql> select user,host,password from user;


  52. +-------+----------------+-------------------------------------------+

  53. | user | host | password |

  54. +-------+----------------+-------------------------------------------+

  55. | root | localhost | *23AE809DDACAF96AF0FD78ED04B6A265E05AA257 |

  56. | root | mysql-svr1 | |

  57. | root | 127.0.0.1 | |

  58. | root | ::1 | |

  59. | repl | 192.168.110.20 | *A424E797037BF97C19A2E88CF7891C5C2038C039 |

  60. | repl | 192.168.111.20 | *A424E797037BF97C19A2E88CF7891C5C2038C039 |

  61. | repl | 192.168.111.30 | *A424E797037BF97C19A2E88CF7891C5C2038C039 |

  62. | repl | 192.168.111.10 | *A424E797037BF97C19A2E88CF7891C5C2038C039 |

  63. | user1 | % | *23AE809DDACAF96AF0FD78ED04B6A265E05AA257 |

  64. | root | 192.168.111.20 | *23AE809DDACAF96AF0FD78ED04B6A265E05AA257 |

  65. | root | 192.168.111.30 | *23AE809DDACAF96AF0FD78ED04B6A265E05AA257 |

  66. | root | 192.168.111.10 | *23AE809DDACAF96AF0FD78ED04B6A265E05AA257 |

  67. | admin | 192.168.111.10 | *4ACFE3202A5FF5CF467898FC58AAB1D615029441 |

  68. | root | % | *23AE809DDACAF96AF0FD78ED04B6A265E05AA257 |

  69. +-------+----------------+-------------------------------------------+

  70. 14 rows in set (0.00 sec)

  71. mysql>


  72. 再次使用密碼登陸成功:


  73. [mysql@LVS01 mysql_5621]$ mysql -uroot -p123 -h292.168.111.10 -P 5621

  74. Warning: Using a password on the command line interface can be insecure.

  75. Welcome to the MySQL monitor. Commands end with ; or \g.

  76. Your MySQL connection id is 20312

  77. Server version: 5.6.21-log Source distribution

  78. Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved.

  79. Oracle is a registered trademark of Oracle Corporation and/or its

  80. affiliates. Other names may be trademarks of their respective

  81. owners.

  82. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

  83. mysql>


  84. 總結:

  85. 出現這個錯誤的原因是同一個用戶有不同主機范圍的權限時,按最匹配的一個主機驗證權限。

  86. 也就是說從192.168.111.99登陸服務器時,驗證順序為:

  87. root@'192.168.111.99'

  88. root@'192.168.111.%'

  89. root@'%'


  90. 參考文檔:

  91. http://dev.mysql.com/doc/refman/5.7/en/connection-access.html

  92. When multiple matches are possible, the server must determine which of them to use. It resolves this issue as follows:


  93. Whenever the server reads the user table into memory, it sorts the rows.


  94. When a client attempts to connect, the server looks through the rows in sorted order.


  95. The server uses the first row that matches the client host name and user name.


  96. The server uses sorting rules that order rows with the most-specific Host values first. Literal host names and IP addresses are the most specific. (The specificity of a literal IP address is not affected by whether it has a netmask, so 192.168.1.13 and 192.168.1.0/255.255.255.0 are considered equally specific.) The pattern '%' means “any host” and is least specific. The empty string '' also means “any host” but sorts after '%'. Rows with the same Host value are ordered with the most-specific User values first (a blank User value means “any user” and is least specific). For rows with equally-specific Host and User values, the order is indeterminate.


  97. 建議:

  98. (1)用戶授權時,按最小主機范圍授權,并且賦予密碼,只授權一次。

  99. (2)如果將來主機范圍變化,重新授權時可刪除舊授權,否則可能因為兩次授權密碼不同導致類似問題。

到此,相信大家對“Mysql連接錯誤ERROR 1045 (28000): Access denied for user問題的解決方法”有了更深的了解,不妨來實際操作一番吧!這里是億速云網站,更多相關內容可以進入相關頻道進行查詢,關注我們,繼續學習!

向AI問一下細節

免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。

AI

怀来县| 西吉县| 简阳市| 集贤县| 郯城县| 安义县| 赞皇县| 昌吉市| 罗田县| 甘孜| 息烽县| 巴彦淖尔市| 南昌县| 大港区| 江北区| 景东| 松原市| 周口市| 当雄县| 海兴县| 晋江市| 新乡县| 岳阳市| 墨竹工卡县| 山西省| 保亭| 桃园市| 泾川县| 岫岩| 安宁市| 新邵县| 濮阳市| 永春县| 赤城县| 麻栗坡县| 东兴市| 东山县| 乌拉特中旗| 青龙| 昌乐县| 桓台县|