一個mysql數(shù)據(jù)庫配置問題導(dǎo)致登錄失敗的解決方案
在一個以mysql數(shù)據(jù)庫為后臺的標(biāo)準(zhǔn)的servlet/tomcat網(wǎng)絡(luò)應(yīng)用中,在待機一天后再次使用時出現(xiàn)了問題,***次登錄總是失敗。通過察看日志發(fā)現(xiàn)如下錯誤:“com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure”。
上述問題是由mysql5數(shù)據(jù)庫配置引起的。mysql5將其連接的等待時間(wait_timeout)缺省為8小時。
- mysql show global variables like 'wait_timeout';
- +---------------+---------+
- | Variable_name | Value |
- +---------------+---------+
- | wait_timeout | 28800 |
- +---------------+---------+
- 1 row in set (0.00 sec)
解決方法:
a. 在my.cnf 或 my.ini 文件中增加或修改'wait_timeout'
[mysqld]
wait_timeout=1814400
b.重新啟動mysql5
mysql字符集問題:
a.進(jìn)入mysql, 查詢字符集
shell> show variables like ''character%''
b.修改數(shù)據(jù)庫默認(rèn)字符集為: utf8
在my.conf( linux path= /etc ) 或 my. ini( windowns ) 找到 [mysqld] 或 [mysql], 修改或增加以下行:
default_character_set=utf8。
c.重啟mysql服務(wù),修改成功。
關(guān)于MySQL數(shù)據(jù)庫配置導(dǎo)致登錄失敗錯誤的解決及字符集的修改的知識就介紹到這里了,希望本次的介紹能夠?qū)δ兴鶐椭?/p>
【編輯推薦】


2009-11-18 16:10:00
2010-05-17 09:49:46




