A solution for Logon failures caused by mysql database configuration problems

Source: Internet
Author: User

InMysql databaseFor standard servlet/tomcat network applications in the background, there is a problem when they are used again after one day of standby, and the First Login always fails. Check the log and find the following error: "com. mysql. jdbc. exceptions. jdbc4.CommunicationsException: Communications link failure ".

The above problem is caused by mysql5Database Configuration. Mysql5 sets the connection wait time (wait_timeout) to 8 hours by default.

 
 
  1. mysql show global variables like 'wait_timeout';  
  2.  
  3. +---------------+---------+  
  4.  
  5. | Variable_name | Value |  
  6.  
  7. +---------------+---------+  
  8.  
  9. | wait_timeout | 28800 |  
  10.  
  11. +---------------+---------+  
  12.  
  13. 1 row in set (0.00 sec) 

Solution:

A. Add or modify 'wait _ timeout' in the my. cnf or my. ini file'

[Mysqld]

Wait_timeout = 1814400

B. Restart mysql5

Mysql Character Set problems:

A. Go to mysql and query the character set

Shell> show variables like ''character %''

B. Modify the default Character Set of the database to utf8.

Find [mysqld] or [mysql] In my. conf (linux path =/etc) or my. ini (windowns), modify or add the following lines:

Default_character_set = utf8.

C. Restart the mysql service. The modification is successful.

This article describes how to solve the logon Failure error caused by MySQL Database Configuration and modify the character set. We hope this article will help you.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.