【转】mysql解决自动断开8小时未曾用过的链接
http://www.cnblogs.com/neonlight/archive/2008/08/25/1276178.html
近一段时间,很多部门同事反映在使用mysql的过程出现数据库连接自动断开的问题,我对该问题做了一些实验。
关于mysql自动断开的问题研究结果如下,在mysql中有相关参数设定,当数据库连接空闲一定时间后,服务器就
会断开等待超时的连接:
1、相关参数,红色部分
mysql> show variables like '%timeout%';
+--------------------------+-------+
| Variable_name | Value |
+--------------------------+-------+
| connect_timeout | 5 |
| delayed_insert_timeout | 300 |
| innodb_lock_wait_timeout| 50 |
| interactive_timeout | 28800 |
| net_read_timeout | 30 |
| net_write_timeout | 60 |
| slave_net_timeout | 3600 |
| wait_timeout | 28800 |
+--------------------------+-------+
同一时间,这两个参数只有一个起作用。到底是哪个参数起作用,和用户连接时指定的连接参数相关,缺省情况下是使用
wait_timeout。我建议是将这两个参数都修改,以免引起不必要的麻烦。
2、修改参数
这两个参数的默认值是8小时。我测试过将这两个参数改为0,结果出人意料,系统自动将这个值设置为1。换句话说,不能将该值设置为永久。我建议为参数值加三个0,这样肯定可以满足我们的应用要求。
修改操作:打开/etc/my.cnf,在属性组mysqld下面添加参数如下:
[mysqld]
interactive_timeout=28800000
wait_timeout=28800000
windows下在my.ini文中增加:
interactive_timeout=28800000
wait_timeout=28800000
相关文档:
由于能直接在MYSQL数据库里添加中文数据,并且能正常显示,说明我的表都使用了正确的字符编码,经过查看后,确认了,我全部的表以及字段都使用了UTF-8的编码,但是为什么程序添加的中文数据就不行呢?
其实,原因在于MYSQL服务器使用的默认编码,以及数据库的默认编码,很多人已经很小心的在建立表时关注表的字符编码,却忽略了数据库 ......
For our four-node, four-host MySQL Cluster, it is necessary to
write four configuration files, one per node host.
Each data node or SQL node requires a
my.cnf
file that provides two pieces of
information: a connectstring
that tells
......
To shut down the cluster, enter the following command in a shell
on the machine hosting the management node:
shell> ndb_mgm -e shutdown
The -e
option here is used to pass a command to
the ndb_mgm
client from the shell. (See
Section 4.23, “ ......
一、导出数据库用mysqldump命令(注意mysql的安装路径,即此命令的路径):
1、导出数据和表结构:
mysqldump -u用户名 -p 数据库名 > 数据库名.sql
#/usr/local/mysql/bin/mysqldump -uroot -p abc > abc.sql
敲回车后会提示输入密码
2、只导出表结构
mysqldump -u用户名 -p -d 数据库名 > 数据库名.sql
# ......
1.配置名字为myodbc的数据源
2.在stdafx.h中加上
#import "c:\program files\common files\system\ado\msado15.dll" no_namespace rename ("EOF", "adoEOF")
3.在程序初始化的方法中加上
AfxEnableControlContainer();
// 初始化COM,创建ADO连接等操作
AfxOleInit();
4.在合适的地方加上
public:_ConnectionPt ......