Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

605
Vistas
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:

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 info listed in my config file (which I believe is correct):

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

This is the main contents 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've looked at answers to similar errors but none of the solutions worked for me. Any help would be appreciated.

over 4 years ago · Santiago Trujillo
2 Respuestas
Responde la pregunta

0

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.

over 4 years ago · Santiago Trujillo Denunciar

0

Encountered the same error and found it was because I haven't started the service yet.

Executed the command systemctl start mariadb and then connected to the MariaDB server using the command mysql and it worked.

Hope it helps

over 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda