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 127.0.0.1 to connect to local MySQL, and the speed is normal.

The My.ini is configured in

bind-address=127.0.0.1

Connect local mysql with localhost: slow speed

<?php$start = Microtime (true); $mysqli = new mysqli (' 127.0.0.1 ', ' 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;

Analysis:
Configuration in 1.my.ini

bind-address=127.0.0.1

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

Bind-address=::1

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

So: In the configuration of the

case, you should use 127.0.0.1 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 127.0.0.1.

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