MySQL remote connection slow-speed solution

Source: Internet
Author: User

I want to connect to a database on my colleague's machine. In the account password everything is correct situation, or encountered a few problems.

1, Firewall
By telnet colleague Machine IP 3306, the result is not even on. have dealt with similar problems. Then you can telnet by shutting down the firewall on your colleague's machine directly.

2, the connection database is very slow
Connecting to the MySQL database in PHP is very slow. I thought there was an exception to the PHP extension. So change CMD to operate, the result connection is still very slow. This makes me rule out the reason for PHP. Baidu, that is because the MySQL connection has the following several steps:
1, DNS resolution of the host of the connection
2, can not resolve, direct current IP connection.

So, by adding a line of code under [Mysqld] in the MySQL configuration file:

Skip-name-resolve to bypass MySQL's DNS resolution when connecting to a remote database

2. When starting the MYSQLD server, attach the –skip-name-resolve option, the same principle as the first

3. Increase the value of host_cache_size, the default value of Host_cache_size is 128 for multiple remote hosts


Because I am using IP to connect, the root DNS resolution is not. So, in the process of parsing, it takes a long time. This period of time causes a DNS resolution timeout. Through the above code, directly let MySQL do not go to DNS resolution.

Note: If you use the –skip-grant-tables system, you will not have access to any user access control, but you can use mysqladmin flush-privileges or mysqladmin reload to open access control; The databases statement is open to all users,
If the MySQL server does not open a remote account, add skip-grant-tables to the My.ini

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.