Quantcast
Channel: 周曙光的网络日志
Viewing all articles
Browse latest Browse all 114

Ubuntu下的mysql自动停止的解决方案

$
0
0
mysql老是自动停止,导致wordpress连接数据库失败,于是我去求助伟大的推神: 我的digtalocean上VPS上的mysql数据库老是自动停掉,这是怎么回事啊?我用的操作系统是 Ubuntu 12.10 , /var/log/ 底下 的mysqld.log mysql.err  mysql.log 都是空的,不知道发生什么事了.过了一会儿,大神出现了:

我输入dmesg,果然发现mysql respawning too fast,的字样了
[422425.267037] send sigkill to 5605 (mysqld), adj 0, size 16693
[422425.348455] init: mysql main process (5605) killed by KILL signal
[422425.356550] init: mysql main process ended, respawning
[422425.811580] init: mysql main process (10805) terminated with status 1
[422425.811629] init: mysql main process ended, respawning
[422426.728623] init: mysql post-start process (10806) terminated with status 1
[422426.779367] init: mysql main process (10840) terminated with status 1
[422426.779402] init: mysql respawning too fast, stopped
[452934.665293] select 1 (init), adj 0, size 285, to kill
[452934.665301] select 379 (rsyslogd), adj 0, size 695, to kill
[452934.665304] select 1006 (apache2), adj 0, size 1975, to kill
[452934.665306] select 18429 (apache2), adj 0, size 10799, to kill
[452934.665309] select 11546 (mysqld), adj 0, size 16458, to kill
[452934.665311] send sigkill to 11546 (mysqld), adj 0, size 16458
[452934.761547] init: mysql main process (11546) killed by KILL signal
[452934.768425] init: mysql main process ended, respawning
[452935.139794] init: mysql main process (17045) terminated with status 1
[452935.139829] init: mysql main process ended, respawning
[452935.157952] init: mysql post-start process (17046) terminated with status 1
[452935.207468] init: mysql main process (17072) terminated with status 1
[452935.207501] init: mysql respawning too fast, stopped

上网搜索 mysql respawning too fast,找到
http://askubuntu.com/questions/127264/cant-start-mysql-mysql-respawning-too-fast-stopped

解决办法是
dpkg-reconfigure mysql-server-5.5
不要先删除低版本的mysql
apt-get remove mysql-server-5.5

再安装
 apt-get install mysql-server-5.5

然后才能使用
dpkg-reconfigure mysql-server-5.5

先试试看,好像mysql还会不会自动停止掉了。

造成mysql自动停止的原因似乎是字符编码问题,不使用上面的方法,可以直接修改 /etc/mysql/my.cnf  文件

要修改 /etc/mysql/my.cnf 里的  [client]和[myslqd] 中的内容,添加指定字体编码
 [client]
default-character-set=utf8

[myslqd]
character_set_server=utf8
collation_server = utf8_general_ci

再reboot服务器,然后dmesg,果然没有 mysql respawning too fast。半天过去了,wordpress也没有出现无法链接数据库了。

参考链接:

Viewing all articles
Browse latest Browse all 114

Trending Articles