Note: This article was originally published in 2014. Some steps, commands, or software versions may have changed. Check the current WordPress documentation for the latest information.
In this step-by-step guide, you’ll learn have wordpress communicate with mysql via socket. WordPress is the world’s most popular content management system (CMS), powering over 40% of all websites on the internet.
Prerequisites
Before you begin, make sure you have:
- WordPress installation (self-hosted)
- Administrator access to WordPress dashboard
- FTP/SFTP or file manager access to server files
How to: Have (http://wordpress.org “WordPress”) communicate with (http://www.mysql.com “MySQL”) via (http://en.wikipedia.org/wiki/Network_socket “Network 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’);
Summary
You’ve successfully learned have wordpress communicate with mysql via socket. If you run into any issues, double-check the prerequisites and ensure your WordPress environment is properly configured.
Related Articles
- Changing file permissions and recommendations for WordPress in a Linux system
- How to: Clean your WordPress database from all the empty Yoast WordPress SEO meta data
- Cómo agregar lenguajes adicionales a tu instalación de Wordpress - Multisitio Multired localización
- How to: Connect to a MySql server using SSL from a WordPress Site