0

几个客户盒子改变了他们的IP,现在这些盒子无法访问数据库。充其量是打开和关闭连接(大部分是关闭的)。其他没有更改 IP 的盒子可以正常访问数据库。顺便说一句,我从网络方面进行了故障排除,没有发现任何问题。我被告知/听说 mysql db 维护某种 ip-hostname 表/查找表?这可能是问题所在。如何解决这个问题?

MySql.Data.MySqlClient.MySqlException: Reading from the stream has failed. ---> System.IO.IOException: Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host. ---> System.Net.Sockets.SocketException: An existing connection was forcibly closed by the remote host
   at System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset, Int32 size)
   --- End of inner exception stack trace ---
   at MyNetworkStream.HandleOrRethrowException(Exception e)
   at MyNetworkStream.Read(Byte[] buffer, Int32 offset, Int32 count)
   at MySql.Data.MySqlClient.TimedStream.Read(Byte[] buffer, Int32 offset, Int32 count)
   at System.IO.BufferedStream.Read(Byte[] array, Int32 offset, Int32 count)
   at MySql.Data.MySqlClient.MySqlStream.ReadFully(Stream stream, Byte[] buffer, Int32 offset, Int32 count)
   at MySql.Data.MySqlClient.MySqlStream.LoadPacket()
4

2 回答 2

0

检查您使用的用户是否在 MysqlWorkbench 中配置了“限制连接到主机匹配”选项

于 2013-09-05T22:41:00.950 回答
0

MySQL 通过用户名和主机名的组合来识别用户帐户。主机名可以是域名或 IP 地址。主机名可以是通配符。请参阅文档

用户帐户存储在系统mysql数据库 table 中user。您可以直接操作它,您可以使用GRANTSQL 语句授予对新 IP 地址的访问权限,例如:

GRANT ALL ON mydatabase.* TO 'myusername'@'123.45.67.%' IDENTIFIED BY 'xyz';

这会将“mydatabase”数据库的所有表的所有权限授予从以“123.45.67”开头的任何 IP 地址连接的用户。用户名“myusername”和密码“xyz”。

您可能需要FLUSH PRIVILEGES在修改用户帐户后发出 SQL 语句。

于 2013-09-05T22:44:05.257 回答