奇怪的连接到远程 mysql 数据库问题

奇怪的连接到远程 mysql 数据库问题

当指定确切的 IP 时,我可以通过命令行连接到我的 mysql 数据库:

 mysql -u root -p -h 172.31.110.55

我在 aws 上,但是当我尝试使用 DNS 连接时,出现此错误:

  $ mysql -u root -p -h ip-172-31-110-55.us-west-2.compute.internal
  ERROR 1045 (28000): Access denied for user 'root'@'ip-172-31-110-55.us-west-2.compute.internal' (using password: YES)

我仔细检查了一下我输入的密码是否正确

mysql> SHOW GRANTS;
+---------------------------------------------------------------------------------------------------------------------------------------------------------+
| Grants for [email protected]                                                                                            |
+---------------------------------------------------------------------------------------------------------------------------------------------------------+
| GRANT ALL PRIVILEGES ON *.* TO 'root'@'ip-172-31-110-55.us-west-2.compute.internal' IDENTIFIED BY PASSWORD '****HASH_OF_PASSWORD****' |
+---------------------------------------------------------------------------------------------------------------------------------------------------------+

这可能是什么问题?我相信这就是我使用 phpmyadmin 远程访问数据库时也会出现错误的原因

  MySQL said: 
 #1045 - Access denied for user 'root'@'ip-172-31-110-55.us-west-2.compute.internal' (using password: YES) 

我的 phpmyadmin 配置文件:

/* Remote Server */
$i++;
$cfg['Servers'][$i]['connect_type'] = 'tcp';
$cfg['Servers'][$i]['auth_type'] = 'config';
$cfg['Servers'][$i]['host'] = 'myinstance.123456789012.us-east-1.rds.amazonaws.com';
$cfg['Servers'][$i]['verbose'] = 'Remote Server Name';
$cfg['Servers'][$i]['user'] = 'root';
$cfg['Servers'][$i]['password'] = '**********'; 
$cfg['Servers'][$i]['hide_db'] = '^(mysql|performance_schema|innodb|information_schema)$';

答案1

我解决了 phpmyadmin 问题(这是我面临的主要问题)。修复过程发布在这里,以供后人参考,因为评论太长了。

/* Remote Server */
$i++;
$cfg['Servers'][$i]['connect_type'] = 'tcp';
$cfg['Servers'][$i]['auth_type'] = 'cookie';
$cfg['Servers'][$i]['host'] = '172.31.110.55';
$cfg['Servers'][$i]['port'] = '3306';
$cfg['Servers'][$i]['verbose'] = 'Remote Server Name';
$cfg['Servers'][$i]['hide_db'] = '^(mysql|performance_schema|innodb|information_schema)$';

我也执行了“mysqladmin -u root 密码‘newpassword’”不知道这是否与此有关。

命令行问题仍然存在。如果有人知道,我很乐意进一步检查。

相关内容