A computer cannot connect to another computer's database __ database

Source: Internet
Author: User
Problems that arise: Communications link failure The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.
Workaround: Reason 1: First, make sure the client computer can ping the server computer. cannot be estimated to be reason 2, can continue this method if possible.

Most of the reason is that the database reclaims the connection, and the system's buffer pool does not know, and continues to use the reclaimed connection.

Take MySQL for example:

The first solution, is the MySQL recovery of idle connections for a long time, MySQL default recovery time is 8 hours, can be in the MySQL directory My.ini add the following configuration, the time to 1 days. Unit is seconds, the maximum seems to be 24 days:

[Mysqld]

wait_timeout=86400

The second solution can be configured to allow the buffer pool to test whether the connection is recycled, and if it is recycled, it will not continue to be used, taking DBCP as an example:

#SQL查询, to verify connections removed from the connection pool
Dbcp.validationquery=select 1
#指明连接是否被空闲连接回收器 (if any) is checked and if the detection fails, the connection is removed from the pool
Dbcp.testwhileidle=true
#在空闲连接回收器线程运行期间休眠的时间值, in milliseconds, generally smaller than minevictableidletimemillis
dbcp.timebetweenevictionrunsmillis=300000
#在每次空闲连接回收器线程 (if any) the number of connections checked at run time, preferably consistent with maxactive
Dbcp.numtestsperevictionrun=50
#连接池中连接, is idle for a period of time and is evicted from the connection pool (1000*60*60) in milliseconds
dbcp.minevictableidletimemillis=3600000

Reason 2:windows Firewall does not allow access. Shut down the firewall, or allow the specified port access.
Reason 3:1. Change Table method. Your account may not be allowed to log in remotely, only in localhost. This time as long as the computer in localhost, login mysql, change the "MySQL" Database in the "User" table in the "host" item, from "localhost" renamed "%" 1.mysql-u root-pvmwaremysql> Use Mysql;mysql>update user set host = '% ' where user = ' root '; mysql>select host, user from user;  2. Authorization law. For example, you want to myuser use MyPassword to connect to a MySQL server from any host. Grant all privileges in *.* to ' myuser ' @ '% ' identified by ' MyPassword ' with GRANT OPTION; If you want to allow the user to connect to the MySQL server from the IP-192.168.1.3 host, and use MyPassword as password GRANT all privileges on *.* ' myuser ' @ ' 192.168.1.3 ' Identified by ' MyPassword ' with GRANT OPTION; 3. In Windows with the exception of the firewall to add 3306 Port summary: mysql-u root-p mysql>use MySQL; Mysql>select ' host ' from user where user= ' root '; Mysql>update User Set host = '% ' where user = ' root '; Mysql>flush privileges; Mysql>select ' host ' from user where user= ' root '; The first sentence is to log in to the second sentence with the permission user root: Select the third sentence of the MySQL library: View the host value of the user table in the MySQL library (the hosts/IP name for connection access) The fourth sentence: Modify the host value (increase the IP address in the wildcard%), Of course, you can add the IP address directly to the fifth sentence: Refresh MySQL system permissions related table sixth sentence: And then review the user table, there are changes. Restart MySQL service to completeYes.
If the first method does not work, check on the Internet, less execution of a statement mysql>flush privileges to make the changes take effect. That's it.

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.