Windows Server R2 and 2012 PHP connection MySQL too slow solution

Source: Internet
Author: User
Compare the speed of the following two scripts:

    • Windows 7 uses localhost to connect to local MySQL at a very slow speed.
    • Windows 7 uses to connect to local MySQL, and the speed is normal.

The My.ini is configured in


Connect local mysql with localhost: slow speed

<?php$start = Microtime (true); $mysqli = new mysqli (' ', ' root ', ' ', ' MySQL '); Connection time is only 0.0025 seconds.//$mysqli = new mysqli (' localhost ', ' root ', ', ' MySQL '); The connection takes more than 1 seconds and is 400 times times slower than normal. Echo Microtime (True)-$start;

Configuration in


, Win7 and above versions of PHP connect MySQL with localhost for more than 1 seconds, 400 times times slower than the connection.
Configuration in


, Win7 and above version of the system PHP with localhost connection mysql speed is normal, but with connection is not normal.
3. Remove Bind-address configuration, it is normal to connect MySQL speed with localhost or

So: In the configuration of the

case, you should use to connect to the local MySQL database.
When installing WordPress, phpMyAdmin and other PHP programs, the default is to use localhost to connect to the local MySQL database, this time attention to the default localhost changed to

In addition, Windows 2008, 2012 and Windows 7 have the same problem.

The above describes the Windows Server R2 and 2012 PHP connection MySQL too slow solution, including aspects of the content, I hope the PHP tutorial interested in a friend helpful.

  • 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: 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.