haenik kamdar haenik kamdar - 1 year ago 137
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.


change your code here, interchange host and database name


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