如何在远程主机中登录mysql DB

时间:2018-12-18 07:13:21

标签: mysql

我在vm1主机中使用mysql,其IP为:10.104.xx.xx。 我可以成功登录数据库,如下所示:

mysql  -uStack -pqwerasdf##123 hpcusers;

并且Stack用户的授予是:

show grants for Stack@'%';

结果:

+--------------------------------------------------------------+
| Grants for Stack@%                                           |
+--------------------------------------------------------------+
| GRANT ALL PRIVILEGES ON *.* TO 'xiezy'@'%' WITH GRANT OPTION |
| GRANT ALL PRIVILEGES ON `hpcusers`.* TO 'xiezy'@'%'          |
+--------------------------------------------------------------+
2 rows in set (0.00 sec)

现在,我想从远程vm2主机登录数据库。我使用:

mysql -h10.104.xx.xx -uStack -pqwerasdf##123 hpcusers    

但是很不幸,我失败了,结果是:

Warning: Using a password on the command line interface can be insecure.
ERROR 2003 (HY000): Can't connect to MySQL server on '10.104.xx.xx' (110)

vm1主机中的mysql版本是

Server version: 5.6.25-73.1 Percona Server (GPL), Release 73.1, Revision 07b797f

vm2主机中的mysql版本为:

Server version: 5.7.24-log MySQL Community Server (GPL)

同时,我可以

ping 10.104.xx.xx

成功在vm2主机中。我可以成功登录vm1

ssh root@10.104.xx.xx

谁可以帮助我?为什么我不能远程登录数据库?

0 个答案:

没有答案