haenik kamdar haenik kamdar - 2 years ago 213
SQL Question

Mysql Operation timeout Error

Warning: mysqli_connect(): (HY000/2002): Operation timed out in /Applications/XAMPP/xamppfiles/htdocs/conn.php on line 4
Connection failed: Operation timed out

Get the following error while connecting to XAMPP on Mac OS X.
Code line is


// Check connection
if (mysqli_connect_errno()) {
echo "Connection failed: " . mysqli_connect_error();

Is it a Mysql Host problem or a Mysql default socket problem and how to resolve it? Default Host is 3306. I dont know where my mysql.sock file is generated and whether its generating or not.

Answer Source

change your code here, interchange host and database name


check php manual for more info : http://php.net/manual/en/function.mysqli-connect.php

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download