Warning: mysqli_real_connect(): (HY000/2002): No such file or directory in wp-includes/wp-db.php in WordPress in XAMPP environment

Tekton Socket Program

Trying to run WordPress in my XAMPP environment shows this error.

Warning: mysqli_real_connect(): (HY000/2002): No such file or directory in wp-includes/wp-db.php

Basically WordPress uses the mysqli extension to connect to the database and uses a mysql socket to connect, which it could not find. Upon checking the phpinfo(), the default socket location is at /tmp/mysql.sock, which may not exist on your file system.

To fix this, simply add a symlink to the mysql.sock file in your XAMPP directory.

ln -s /Applications/XAMPP/xamppfiles/var/mysql/mysql.sock /tmp/mysql.sock

 

Tags

Add new comment

Plain text

  • No HTML tags allowed.
  • Lines and paragraphs break automatically.
  • Web page addresses and email addresses turn into links automatically.