我已创建用户并授予所有权限,但仍无法使用该用户连接到SQL。请问有人可以帮忙解决吗?
所跟进的步骤: mysql --user=root mysql;
CREATE USER 'db_user'@'%' IDENTIFIED BY 'password';
CREATE USER 'db_user'@'localhost' IDENTIFIED BY 'password';
CREATE USER 'db_user'@'hostname' IDENTIFIED BY 'password';
GRANT ALL PRIVILEGES ON *.* TO 'db_user'@'%' WITH GRANT OPTION;
GRANT ALL PRIVILEGES ON *.* TO 'db_user'@'localhost' WITH GRANT OPTION;
GRANT ALL PRIVILEGES ON *.* TO 'db_user'@'hostname' WITH GRANT OPTION;
当我尝试连接时:
mysql -u db_user -ppassword -h 'hostname'
我收到了这个错误。
ERROR 1045 (28000): Access denied for user 'db_user'@'hostname' (using password: YES)
MariaDB [(none)]> show grants for db_user@'hostname';
GRANT ALL PRIVILEGES ON *.* TO 'db_user'@'hostname' IDENTIFIED BY PASSWORD '*2470C0C06DEE42FD1618BB99005ADCA2EC9D1E19' WITH GRANT OPTION
1 row in set (0.00 sec)
它缺少什么导致无法连接?
'db_user'@'hostname'
中,hostname
是指你正在连接的地址的主机名吗? - ʰᵈˑ