It takes for my local system about 1 second to establish a MySQLi connection. Code:
$db = new mysqli( 'localhost', 'root', 'pass', 'mydb' );
Why is it so slow? Is this normal? Can I improve it?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Switch “localhost” to 127.0.0.1.
So, instead of:
Use:
Seeing as this question seems to be pretty popular and a lot of people would like to know WHY this is happening:
Worth noting that this problem only seems to occur with Windows 7 and after. Before Windows 7, localhost resolution was handled by the hosts file, which came pre-configured with
127.0.0.1