Mariadb error - Cannot connect to local server through socket

Mariadb error - Cannot connect to local server through socket

Colleagues hello to all.

In today's article, we'll talk about the issue when connecting to the Mariadb database after moving the database files to another location.

 

The problem is called - "ERROR 2002 (HY000): Can't connect to local server through socket '/var/lib/mysql/mysql.sock' (2)".

mariadb_socket

This problem occurs when you move the database to another directory and specify the new directory in the configuration file via the datadir variable, but forget to specify another variable.

 

To solve this problem, you need to add the path to the "socket" socket file in the configuration file. You need to write the path to the socket not only in the server.cnf file, but also in client.cnf.

In my case, my database files are stored in the "/app/mysql/data" so I will add the socket file to this directory.

conf> socket = /app/mysql/data/socket.sock

mariadb_socket

mariadb_socket

 

Restarting the database.

$. service mariadb restart


 

Thank you all, I hope that my article helped you in some way.

SIMILAR ARTICLES

MariaDB - ERROR Incorrect definition of table
MariaDB - ERROR Incorrect definition of table
MARIADB
Read more
Mariabackup backup - gzip compression
Mariabackup backup - gzip compression
MARIADB
Read more
Mariabackup error - Error writing file UNKNOWN errno 32 Broken pipe
Mariabackup error - Error writing file UNKNOWN errno 32 Broken pipe
MARIADB
Read more