php – mysql_connect保持打开多长时间?
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了php – mysql_connect保持打开多长时间?,小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含941字,纯文字阅读大概需要2分钟。
内容图文
![php – mysql_connect保持打开多长时间?](/upload/InfoBanner/zyjiaocheng/909/89229019acba49d3aced33d35e040dee.jpg)
我有一个CLI脚本,当你第一次启动时:
function __construct(){$this->connectToDatabase();}
protected function connectToDatabase(){
try{
$this->databaseName = $this->dbname;
$this->posName = $this->posName;
$this->vlog = $this->vlogName;
$this->database = mysql_connect($this->dbhost, $this->dbuser, $this->dbpass);
mysql_select_db($this->databaseName, $this->database);
}
catch(Exception $e){
$this->console($e);
}
}
此CLI脚本可以保持运行数天.我如何保持mysql连接打开?或者在每个mysql_query之前,我必须检查连接是否仍然打开?
这是我得到的错误:
MySQL Error: MySQL server has gone away
解决方法:
检查一下:https://www.digitalocean.com/community/questions/how-to-set-no-timeout-to-mysql
特别指出:
The server timed out and closed the
connection. By default, the server
closes the connection after 8 hours or
28800 seconds if nothing has happened.
You can change the time limit by
setting the wait_timeout variable when
you start mysqld via your server’s
/etc/my.cnf […]
内容总结
以上是互联网集市为您收集整理的php – mysql_connect保持打开多长时间?全部内容,希望文章能够帮你解决php – mysql_connect保持打开多长时间?所遇到的程序开发问题。 如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
扫描二维码推送至手机访问。