This article introduces how to resolve the slow connection to local MySQL in Windows 7/8. For more information, see the reference.
After setting up the PHP environment in Windows 7 last time, I went online to find some PHP source code for debugging. These PHP can run perfectly, and some of them need to install the mysql database, I downloaded and installed mysql-5.1.51 and phpMyAdmin-3.3.7. However, every time the installation program reaches the configuration database step, it cannot connect to the mysql database. I can make sure that the database username and password are correct, and this is also the case for whatever program to install.
I checked mysql and found no problem. My mysql server uses the local address localhost, default root and empty password, and phpMyAdmin can be used to connect to the mysql database, baidu has not found the answer for many times. If you want to test the machine again today, you can enter the IP address 127.0.0.1 when you think of the local address. This was just a try, but you did not expect the installation to be successful.
We know that localhost and 127.0.0.1 are both local addresses. If you enter localhost, the system will automatically resolve it to 127.0.0.1, and my phpMyAdmin will also be opened with the address localhost, it indicates that the localhost has been resolved to 127.0.0.1, but you do not know why you cannot use the localhost address to connect to the mysql database.
Because the default database address localhost installed by most PHP programs is changed to 127.0.0.1 every time, it is a little troublesome. It is easy to understand the principle, we can modify the HOSTS file to achieve our goal. First, use NotePad to open the HOSTS file "C: \ WINDOWS \ system32 \ drivers \ etc \ hosts". Then, add "127.0.0.1 localhost" to it and save the solution.