简体   繁体   English

python mysql数据库连接错误

[英]python mysql database connection error

I am trying to access the remote database from one Linux server to another which is connected via LAN. 我正在尝试从一台Linux服务器访问另一台通过LAN连接的远程数据库。

but it is not working.. after some time it will generate an error 但它不起作用..一段时间后,它将产生一个错误

`_mysql_exceptions.OperationalError: (2003, "Can't connect to MySQL server on '192.168.0.101' (99)")' _mysql_exceptions.OperationalError:(2003年,“无法连接到192.168.0.101(99)的MySQL服务器”))

this error is random it will raise any time. 此错误是随机的,随时都会出现。 each time create a new db object in all methods. 每次在所有方法中创建一个新的db对象。 and close the connection as well then also why this error raise. 并关闭连接,然后还要说明为什么会出现此错误。 can any one please help me to sort out this problem 谁能帮我解决这个问题

This issue is due to so many pending request on the remote database. 此问题是由于远程数据库上有太多待处理的请求所致。

So in this situation MySql closes the connection to the running script. 因此,在这种情况下, MySql关闭与正在运行的脚本的连接。

to overcome this situation put 克服这种情况

time.sleep(sec) # here int is a seconds in number that to sleep the script. time.sleep(sec) #此处int是睡眠脚本的秒数。

it will solve this issue.. without transferring database to local server or any other administrative task on mysql 它将解决此问题..而无需将数据库传输到本地服务器或mysql上的任何其他管理任务

我的解决方案是为一个提交语句收集更多查询(如果这些查询是插入查询)。

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

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