mysql 5.5 任意使用者不加密碼均能登入解決方法
阿新 • • 發佈:2019-01-23
mysql版本5.5:
在新增使用者及賦予許可權的過程中,發現用任意使用者不需要新增任何密碼均能登入,(而加了密碼卻不能登入),如:
# mysql -u monitorshowsssaaaaaaaaaa
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 327
Server version: 5.5.13-rel20.4-log Percona Server with XtraDB (GPL), Release rel20.4, Revision 138
Copyright (c) 2000, 2010, 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 databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| test |
+--------------------+
2 rows in set (0.00 sec)
但許可權只限於test的資料庫。
以root使用者登入,檢視user表:
mysql> select user,host,password from mysql.user;
+-----------------+----------------------------+-------------------------------------------+
| user | host | password |
+-----------------+----------------------------+-------------------------------------------+
| root | localhost | *00EEFBA06C5B79E87B09C3713FCE2CB9965A1DFE |
| root | HZ-D15-02-geyan09120.getui | |
| root | 127.0.0.1 | |
| root | ::1 | |
| | localhost | |
| | HZ-D15-02-geyan09120.getui | |
| gexingeyanmdp | % | *186A5CCB6AC9C6589E5C63913AA1196976131B64 |
| monitor | % | *6F026364683BA7E8AF7ECCCF1BED682117388698 |
+-----------------+----------------------------+-------------------------------------------+
發現有兩個空的user,且password也為空。
將其刪除:
mysql> delete from mysql.user where user='';
Query OK, 2 rows affected (0.00 sec)
並重新整理:
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
然後再重新登:
# mysql -u monitorshowsssaaaaaaaaaa
ERROR 1045 (28000): Access denied for user 'monitorshowsssaaaaaaaaaa'@'localhost' (using password: NO)
發現會有報錯,恢復正常。
注:
空使用者的話,表示任意使用者都可以訪問;
他所對應的密碼為空,所以,如果輸入密碼反而不能登陸;
刪除空使用者後需要重新整理。
在新增使用者及賦予許可權的過程中,發現用任意使用者不需要新增任何密碼均能登入,(而加了密碼卻不能登入),如:
# mysql -u monitorshowsssaaaaaaaaaa
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 327
Server version: 5.5.13-rel20.4-log Percona Server with XtraDB (GPL), Release rel20.4, Revision 138
Copyright (c) 2000, 2010, 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 databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| test |
+--------------------+
2 rows in set (0.00 sec)
但許可權只限於test的資料庫。
以root使用者登入,檢視user表:
mysql> select user,host,password from mysql.user;
+-----------------+----------------------------+-------------------------------------------+
| user | host | password |
+-----------------+----------------------------+-------------------------------------------+
| root | localhost | *00EEFBA06C5B79E87B09C3713FCE2CB9965A1DFE |
| root | HZ-D15-02-geyan09120.getui | |
| root | 127.0.0.1 | |
| root | ::1 | |
| | localhost | |
| | HZ-D15-02-geyan09120.getui | |
| gexingeyanmdp | % | *186A5CCB6AC9C6589E5C63913AA1196976131B64 |
| monitor | % | *6F026364683BA7E8AF7ECCCF1BED682117388698 |
+-----------------+----------------------------+-------------------------------------------+
發現有兩個空的user,且password也為空。
將其刪除:
mysql> delete from mysql.user where user='';
Query OK, 2 rows affected (0.00 sec)
並重新整理:
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
然後再重新登:
# mysql -u monitorshowsssaaaaaaaaaa
ERROR 1045 (28000): Access denied for user 'monitorshowsssaaaaaaaaaa'@'localhost' (using password: NO)
發現會有報錯,恢復正常。
注:
空使用者的話,表示任意使用者都可以訪問;
他所對應的密碼為空,所以,如果輸入密碼反而不能登陸;
刪除空使用者後需要重新整理。