简体   繁体   English

mysql客户端更改IP

[英]mysql client changes IP

several of client boxes changed their IPs and now those boxes can not access the database. 几个客户端框更改了其IP,现在这些框无法访问数据库。 at best the connection is on and off (mostly off). 充其量,连接处于打开和关闭状态(大多数情况下处于关闭状态)。 other boxes which do not have their IPs changed can access the db fine. 其他未更改其IP的邮箱可以访问db。 btw, I have troubleshoot from networking side and found no issue. 顺便说一句,我有网络方面的故障排除,没有发现任何问题。 I have been told/heard that mysql db maintain somekind of ip-hostname tables/lookup table? 我被告知/听说mysql db维护了某种ip-hostname表/ lookup表? could this be the problem . 这可能是问题吗? how to solve this? 如何解决呢?

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()

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

MySQL identifies user accounts by combination of username and hostname. MySQL通过用户名和主机名的组合来识别用户帐户。 The hostname can be domain name or IP address. 主机名可以是域名或IP地址。 The hostname can be wildcarded. 主机名可以通配。 See the documentation . 请参阅文档

User accounts are stored in the system mysql database, table user . 用户帐户存储在系统mysql数据库的表user You can manipulate it directly, on you can use GRANT SQL statement to grant access for your new IP addresses, for example: 您可以直接操作它,可以使用GRANT SQL语句授予对新IP地址的访问权限,例如:

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

This will grant all privileges on all tables of “mydatabase” database to users connecting from any IP address starting with “123.45.67.” with username “myusername” and password “xyz”. 这会将“ mydatabase”数据库所有表上的所有特权授予从“ 123.45.67”开头的任何IP地址(用户名“ myusername”和密码“ xyz”)连接的用户。

You might need to issue FLUSH PRIVILEGES SQL statement after modifying user accounts. 修改用户帐户后,您可能需要发出FLUSH PRIVILEGES SQL语句。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM