几个客户端盒改变了他们的IP,现在这些盒子无法访问数据库。最好是连接打开和关闭(大部分关闭)。没有更改IP的其他框可以访问db罚款。顺便说一句,我从网络方面排除故障,没有发现任何问题。我被告知/听说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()
答案 0 :(得分:0)
检查您使用的用户是否在Mysql Workbench中配置了“限制连接到主机匹配”选项
答案 1 :(得分:0)
MySQL通过用户名和主机名的组合识别用户帐户。主机名可以是域名或IP地址。主机名可以是通配符。请参阅the documentation。
用户帐户存储在系统mysql
数据库,表user
中。您可以直接操作它,您可以使用GRANT
SQL statement授予对新IP地址的访问权限,例如:
GRANT ALL ON mydatabase.* TO 'myusername'@'123.45.67.%' IDENTIFIED BY 'xyz';
这会将“mydatabase”数据库的所有表上的所有权限授予从以“123.45.67。”开头的任何IP地址连接的用户名“myusername”和密码“xyz”。
修改用户帐户后,您可能需要发出FLUSH PRIVILEGES
SQL语句。