CI框架出现 mysql server has gone away的解决办法
来源:互联网 发布:暗黑战神 源码 编辑:程序博客网 时间:2024/06/03 22:00
项目中测试环境后台运行的php进程出现mysql server has gone away的问题,但同样的代码和配置线上环境没有问题。
研究半天后来重启测试环境后台进程,问题就没有了。(线上环境进程会定时重启)
因此CI框架中出现这个问题可以将db配置设置成
$db['default']['pconnect'] = FALSE;
开启pconnect的作用是:
- 当连接的时候本函数将先尝试寻找一个在同一个主机上用同样的用户名和密码已经打开的(持久)连接,如果找到,则返回此连接标识而不打开新连接。
- 其次,当脚本执行完毕后到 SQL 服务器的连接不会被关闭,此连接将保持打开以备以后使用(mysql_close() 不会关闭由 mysql_pconnect() 建立的连接)
下面是在stackoverflow上找到的该配置优缺点,就不翻译了
- If you have:
- Dedicated web server and database hardware in production
- and have tuned the web server and database correctly
- and have an accurate production-like test environment
- And still think your performance problems are caused by database connection time,
CONSIDER turning it on
Persistent connections can cause
- Bugs because some connection state persisted unintentionally (this is a biggie!)
- Database connection limits to be exceeded
- Database performance to drop because of lots of ram used by the many (mostly idle) connections
- Bugs because connections have gone "stale" and the app didn't notice
But CAN
- Reduce latency on initial connection
阅读全文
0 0
- CI框架出现 mysql server has gone away的解决办法
- MySQL server has gone away 的解决办法
- MySQL server has gone away 解决办法
- MySQL server has gone away解决办法
- MySQL server has gone away解决办法
- MYSQL server has gone away解决办法
- MySQL server has gone away的几种解决办法
- 关于mysql has gone away的解决办法
- mysql server has gone away的原因
- MySQL server has gone away的解决方法
- MySQL server has gone away的问题解决
- MySQL server has gone away
- MySQL server has gone away
- MySQL server has gone away
- MySQL server has gone away
- MySQL server has gone away
- MySQL server has gone away
- MySQL server has gone away
- Count the string
- 微信公众号开发---消息模板的使用
- Hadoop--HIVE所谓“集群”
- java 关键字
- Android测试-monkeyRun
- CI框架出现 mysql server has gone away的解决办法
- Lemon Judge OI评测机 | 资源及使用教程 | 比Cena更稳定的评测机 | 已完结
- ESB之Mule ESB的使用
- 大牛博客名录
- echarts的关系图初级成品
- [bigata-114] centos7.2安装mongo 3.2
- SeekBar初识
- HDU
- Error:Execution failed for task ':app:processDebugManifest'. > Manifest merg