Skip to content
Advertisement

Can’t connect to local MySQL server through socket ‘/var/lib/mysql/mysql.sock’ (2)

I just manually installed a new plugin on my WordPress site, created a table in MySQL for the plugin’s entries, and when I try to open the page that uses the plugin, I receive this error:

JavaScript

This is the MySQL info listed in my config file (which I believe is correct):

JavaScript

This is the main contents of the /etc/my.cnf file:

JavaScript

I’ve looked at answers to similar errors but none of the solutions worked for me. Any help would be appreciated.

Advertisement

Answer

Here’s what helped me solve this problem, which was that the actual file directory on my server was /var/lib/mysql/mysql.sock, not /var/lib/mysqld/mysqld.sock:

  1. Open your my.cnf file
  2. Add the following to your [client] section (if you don’t have a [client] section, then add it). It should look like this:

[client]

socket=/var/lib/mysql/mysql.sock

The error should be gone. Many thanks to @alvits for pointing me in the right direction.

User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement