我使用最新的MariaDB docker映像创建了一个用户xyz,其凭据与根用户的凭据相同:
mysql> SELECT User, Host FROM mysql.user;
+-------------+-----------+
| User | Host |
+-------------+-----------+
| root | % |
| xyz | 127.0.0.1 |
| healthcheck | 127.0.0.1 |
| healthcheck | ::1 |
| xyz | localhost |
| healthcheck | localhost |
| mariadb.sys | localhost |
| root | localhost |
+-------------+-----------+
和
mysql> show grants for xyz@'127.0.0.1';
+-----------------------------------------------------------------------------------------------------------------------+
| Grants for xyz@127.0.0.1 |
+-----------------------------------------------------------------------------------------------------------------------+
| GRANT ALL PRIVILEGES ON *.* TO `xyz`@`127.0.0.1` IDENTIFIED BY PASSWORD '*something' |
| GRANT ALL PRIVILEGES ON `somedatabase`.* TO `xyz`@`127.0.0.1` |
+-----------------------------------------------------------------------------------------------------------------------+
但是,我可以以根用户身份登录,但不能以xyz用户身份登录:
bash> mysql -uroot -h 127.0.0.1 -P3308 -p
Enter password:
Welcome to the MySQL monitor. Comm和s end with ; or \g.
Your MySQL connection id is 19
....
bash> mysql -uxyz -h 127.0.0.1 -P3308 -p
Enter password:
ERROR 1045 (28000): Access denied for user 'xyz'@'172.17.0.1' (using password: YES)
你知道可能会发生什么事吗?如何调查这一问题?