Using WordPress with a MySQL Unix Socket

Find the path to your MySQL Unix socket:

netstat -ln | grep "unix.*mysql"

The path should look similar to this:


Edit the DB_HOST directive in your wp-config.php and add your socket path after localhost:

define('DB_HOST', 'localhost:/var/lib/mysql/mysql.sock');


1 thought on “Using WordPress with a MySQL Unix Socket

  1. GGedde

    Unfortunately, having ‘localhost’ in did not work for me. This might be because I have networking disabled.
    Instead using “:/run/mysql/mysqld.sock” worked for me. Notice the : at the front.



Leave a Reply

Your email address will not be published. Required fields are marked *

Markdown is allowed in comments.