«

»

Feb 24

How to: Have WordPress communicate with MySQL via Socket

How to: Have WordPress communicate with MySQL via Socket

As I keep looking into how to improve the performance of website one of the recurrent points mentioned is to use Linux sockets where possible. I really don’t have much experience and I can see how avoiding the TCP stack might help but I figured at least it couldn’t hurt. If you are able to establish a socket connection to MySQL you might also be in the camp of those interested in having WordPress connect to MySQL via a Linux socket connection vs using an IP Address. I searched but it seems there are not that many people doing this, so I thought I would share it so you can also give it a try to your site if you want.

The standard way to connect to a host is:

servername:/route/to/mysql.sock

by default this might look like this for many people:

localhost:/var/run/mysqld/mysqld.sock

so your wp-config.php file would look like this:

/** MySQL hostname */
define(‘DB_HOST’, ‘localhost:/var/run/mysqld/mysqld.sock’);

Enhanced by Zemanta

Leave a Reply

%d bloggers like this: