2

我尝试连接到 Windows 7 上的远程服务器(MariaDB 10)。

my.ini 中的服务器设置

datadir=E:/MariaDB 10/data
port=3306
sql_mode="STRICT_TRANS_TABLES,NO_ENGINE_SUBSTITUTION"
default_storage_engine=innodb
innodb_buffer_pool_size=2042M
innodb_log_file_size=50M
feedback=ON
character-set-server=utf8
skip-name-resolve
[client]
port=3306

用户授予权限如下

GRANT ALL PRIVILEGES ON *.* TO 'remote'@'%' IDENTIFIED BY PASSWORD

我试过这些命令

>> nc -vz ip port
found 0 associations
found 1 connections:
1:  flags=82<CONNECTED,PREFERRED>
outif en0
src 192.168.31.242 port 58576
dst xxx.xxx.xx.xx port xxxx
rank info not available
TCP aux info available
Connection to xxx.xxx.xx.xx port xxx [tcp/creativepartnr] succeeded!

>>telnet xxx.xxx.xx.xx port
Trying xxx.xxx.xx.xx...
Connected to xxx.xxx.xx.xx.
Escape character is '^]'.
Connection closed by foreign host.



>>mysql -uremote -p -hxxx.xxx.xx.xx --port=xxxx
ERROR 2013 (HY000): Lost connection to MySQL server at 'reading initial communication packet', system error: 54

立即得到错误响应。

找不到任何其他人的系统错误情况:54。

我在 localhost 上使用 ip 和端口尝试了相同的 mysql 命令,它可以登录。

  1. 是交换机上的防火墙设置问题吗?(使用命令 nc -vz 可以正常工作。)
  2. 是数据库设置问题吗?(在本地主机上运行良好。)
4

1 回答 1

0

我有同样的问题。我阅读了许多帖子,但没有找到任何答案。就我而言,我可以从某些计算机成功连接,但不能从我的笔记本电脑连接。原因是 3306 端口被公司封锁。我可以通过 ssh 隧道(端口 22)连接到 mysql 服务器。您可以要求您的公司开放端口或使用 ssh。希望这可以帮助其他不浪费时间寻找解决方案的人。您会看到以毫秒为单位的错误消息:

错误 2013 (HY000):在“读取初始通信数据包”时丢失与 MySQL 服务器的连接,系统错误:54

于 2016-03-22T00:44:14.573 回答