Unable to 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 entries, and when I try to open a page using the plugin, I get this error:

DataTables warning (table id = 'to-do_list'): An error occurred while 
connecting to the database 'wordpress_clouse'. The error reported by the 
server was: SQLSTATE[HY000] [2002] Can't connect to local MySQL server 
through socket '/var/lib/mysql/mysql.sock' (2)

This is the MySQL information provided in my configuration file (which I believe is correct):

"type" => "Mysql",
"user" => "root",
"pass" => "******",
"host" => "localhost",
"port" => "",
"db"   => "******"

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

# The following options will be passed to all MySQL clients
[client]
#port       = 3306
socket      = /var/run/mysqld/mysqld.sock

# The MySQL server
[mysqld]
#port       = 3306
socket      = /var/run/mysqld/mysqld.sock
log_error   = mysqld.err

skip-networking

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

+3
source share
2 answers

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

  • my.cnf
  • [client] ( [client], ). :

[]

= //Library/MySQL/mysql.sock

. @alvits , .

+8

, , .

systemctl start mariadb, MariaDB mysql, .

,

+1

All Articles