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

溫馨提示×

溫馨提示×

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

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

Mysql 5.5 源碼安裝后創建用戶報錯"ERROR 1045 (28000): Access denied for user"

發布時間:2020-08-08 08:23:20 來源:ITPUB博客 閱讀:152 作者:feelpurple 欄目:MySQL數據庫
安裝MySQL后,root用戶可設置密碼登錄,其他新建的用戶不能通過密碼登錄,只能不輸入密碼登錄,而且對新建用戶的授權均無效。


--創建一個庫和用戶
mysql> create database fire;
Query OK, 1 row affected (0.00 sec)

mysql> create user neo identified by 'Mysql#2015';
Query OK, 0 rows affected (0.00 sec)

mysql> grant select,create,update,delete on fire.* to neo;
Query OK, 0 rows affected (0.00 sec)

mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)

--使用新用戶登錄報錯

[root@localhost data]# ./bin/mysql -u neo -p"Mysql#2015"
ERROR 1045 (28000): Access denied for user 'neo'@'localhost' (using password: YES)

--但是不輸入密碼卻可以登錄

[root@localhost software]# ./bin/mysql -uneo
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 11
Server version: 5.5.48-log production environment

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

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

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

mysql> show grants;
+--------------------------------------+
| Grants for @localhost                |
+--------------------------------------+
| GRANT USAGE ON *.* TO ''@'localhost' |
+--------------------------------------+
1 row in set (0.00 sec)

報錯原因Mysql使用源碼安裝后,數據庫中存在匿名用戶,可以通過任意用戶名不輸入密碼即可登錄數據庫。

mysql> select host,user,password  from mysql.user where (user) not in ('root');
+-----------------------+------+-------------------------------------------+
| host                  | user | password                                  |
+-----------------------+------+-------------------------------------------+
| localhost             |      |                                           |
| localhost.localdomain |      |                                           |
| %                     | neo  | *CC4C777F1511C297751B78287D6E05345D227819 |
| %                     | test | *443EF031E558E317B19BAD70BDF4E25FA73A89A7 |
+-----------------------+------+-------------------------------------------+
4 rows in set (0.00 sec)

mysql> select host,user,password  from mysql.user where (user) not in ('root','neo','test');
+-----------------------+------+----------+
| host                  | user | password |
+-----------------------+------+----------+
| localhost             |      |          |
| localhost.localdomain |      |          |
+-----------------------+------+----------+
2 rows in set (0.00 sec)

解決方法刪除匿名用戶

mysql> delete  from mysql.user where (user) not in ('root','neo','test');
Query OK, 2 rows affected (0.00 sec)

mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)

之后新創建的用戶即可正常登錄到數據庫

[root@localhost software]# ./bin/mysql -uneo -p'Mysql#2015'
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.5.48-log production environment

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

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

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

mysql> show grants;
+-----------------------------------------------------------------+
| Grants for neo@%                                                |
+-----------------------------------------------------------------+
| GRANT USAGE ON *.* TO 'neo'@'%' IDENTIFIED BY PASSWORD <secret> |
| GRANT SELECT, INSERT, DELETE, CREATE ON `fire`.* TO 'neo'@'%'   |
+-----------------------------------------------------------------+
2 rows in set (0.00 sec)

向AI問一下細節

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

AI

长宁县| 儋州市| 灵寿县| 丰城市| 开封市| 三河市| 萨嘎县| 灵宝市| 黄骅市| 岳阳县| 绍兴市| 黄平县| 沙河市| 平舆县| 麟游县| 龙南县| 中方县| 江津市| 宁武县| 邵阳市| 尼木县| 浦东新区| 郸城县| 永德县| 军事| 泸西县| 石棉县| 西昌市| 陆良县| 鹤峰县| 红安县| 遂川县| 广水市| 鞍山市| 花莲县| 左贡县| 田东县| 扶余县| 南投市| 武冈市| 青铜峡市|