使用此命令检查可能的输出
mysql> select user,host,password from mysql.user;
输出
mysql> select user,host,password from mysql.user;
+-------+-----------------------+-------------------------------------------+
| user | host | password |
+-------+-----------------------+-------------------------------------------+
| root | localhost | *8232A1298A49F710DBEE0B330C42EEC825D4190A |
| root | localhost.localdomain | *8232A1298A49F710DBEE0B330C42EEC825D4190A |
| root | 127.0.0.1 | *8232A1298A49F710DBEE0B330C42EEC825D4190A |
| admin | localhost | *2470C0C06DEE42FD1618BB99005ADCA2EC9D1E19 |
| admin | % | |
+-------+-----------------------+-------------------------------------------+
5 rows in set (0.00 sec)
- 在此用户中,尽管您已授予权限,但不允许管理员从其他主机登录。原因是用户 admin 没有被任何密码识别。
再次使用 GRANT 命令授予用户 admin 密码
mysql> GRANT ALL PRIVILEGES ON *.* TO 'admin'@'%' IDENTIFIED by 'password'
然后检查 GRANT LIST 输出会像他的
mysql> select user,host,password from mysql.user;
+-------+-----------------------+-------------------------------------------+
| user | host | password |
+-------+-----------------------+-------------------------------------------+
| root | localhost | *8232A1298A49F710DBEE0B330C42EEC825D4190A |
| root | localhost.localdomain | *8232A1298A49F710DBEE0B330C42EEC825D4190A |
| root | 127.0.0.1 | *8232A1298A49F710DBEE0B330C42EEC825D4190A |
| admin | localhost | *2470C0C06DEE42FD1618BB99005ADCA2EC9D1E19 |
| admin | % | *2470C0C06DEE42FD1618BB99005ADCA2EC9D1E19 |
+-------+-----------------------+-------------------------------------------+
5 rows in set (0.00 sec)
如果需要允许所需用户(例如用户“admin”)登录,则使用一次 GRANT 命令并执行该命令。
现在应该允许用户登录。