mysql数据库连接不定时报错,no operations allowed...
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了mysql数据库连接不定时报错,no operations allowed...相关的知识,希望对你有一定的参考价值。
问题:数据库连接时不时自动断开,网上查了下,说有可能是mysql超过8小时未操作自动关闭
涉及技术:tomcat数据源,jdbc,spring
帮忙看看如何解决这个自动断开连接的问题
validationQuery = "SELECT 1"
testWhileIdle = "true"
timeBetweenEvictionRunsMillis = "180000"
minEvictableIdleTimeMillis = "3590000"
testOnBorrow="true"追问
能简单解释下这样加的意义是什么吗?
追答你要求太多了。。
已经装了MySQL-python,但在引用时报错:ImportError: No module named MySQLdb
导入MySQLdb模块的时候报错,如下
>>> import MySQLdb
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named MySQLdb
在网上找了一个解决方法:
yum install MySQL-python (centos系统)
再次导入的时候还是报错,怀疑是版本问题:
$ python --version
Python 2.7.10
$ cat /etc/issue
CentOS release 5.11 (Final)
Kernel \r on an \m
这个版本的系统默认装的是python2.4的模块:
$ rpm -ql MySQL-python
/usr/lib64/python2.4/site-packages/MySQL_python-1.2.3c1-py2.4.egg-info
/usr/lib64/python2.4/site-packages/MySQL_python-1.2.3c1-py2.4.egg-info/PKG-INFO
/usr/lib64/python2.4/site-packages/MySQL_python-1.2.3c1-py2.4.egg-info/SOURCES.txt
/usr/lib64/python2.4/site-packages/MySQL_python-1.2.3c1-py2.4.egg-info/dependency_links.txt
/usr/lib64/python2.4/site-packages/MySQL_python-1.2.3c1-py2.4.egg-info/top_level.txt
/usr/lib64/python2.4/site-packages/MySQLdb
........
........
解决方法:
1,在官网下载MySQL-python-1.2.5。https://pypi.python.org/pypi/MySQL-python
2,unzip MySQL-python-1.2.5.zip
3,安装
cd MySQL-python-1.2.5
python setup.py build
python setup.py install再次装载模块的时候还是报错:
>>> import MySQLdb
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "build/bdist.linux-x86_64/egg/MySQLdb/__init__.py", line 19, in <module>
File "build/bdist.linux-x86_64/egg/_mysql.py", line 7, in <module>
File "build/bdist.linux-x86_64/egg/_mysql.py", line 6, in __bootstrap__
ImportError: libmysqlclient.so.18: cannot open shared object file: No such file or directory
根据最后提示,应该是找不着一个交libmysqlclient.so.18的文件,于是到mysql安装目录里找到这个文件并且做一个软连接到/usr/lib
ln -sv /usr/local/ver01/percona/lib/libmysqlclient.so.18 /usr/lib64/libmysqlclient.so.18
再次装载模块的时候不再报错了。
本文出自 “一直在路上” 博客,请务必保留此出处http://chenql.blog.51cto.com/8732050/1760899
以上是关于mysql数据库连接不定时报错,no operations allowed...的主要内容,如果未能解决你的问题,请参考以下文章
springboot 连接 mysql 时报错 using password: NO
报错集:给新创建的MySQL数据库设置用户密码时报错(error: ‘Access denied for user ‘root‘@‘localhost‘ (using password: NO))
报错集:给新创建的MySQL数据库设置用户密码时报错(error: ‘Access denied for user ‘root‘@‘localhost‘ (using password: NO))(代
Django项目与mysql交互进行数据迁移时报错:AttributeError: 'str' object has no attribute 'decode'(示例代
已经装了MySQL-python,但在引用时报错:ImportError: No module named MySQLdb