lamp icon indicating copy to clipboard operation
lamp copied to clipboard

mysqldump failed cannot connect to /var/run/mysqld/mysqld.sock

Open jazzi opened this issue 3 years ago • 3 comments

Hi, got the following error while running mysqldump -u user -p databasename > new.sql

mysqldump: Got error: 2002: Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2) when trying to connect

Trying to run backup.sh after edited the config, it shows the error as below.

2022-06-02 10:13:42 Backup progress start
2022-06-02 10:13:42 MySQL dump start
2022-06-02 10:13:42 MySQL all databases backup failed

So where is the mysqld.sock? Is this missing file the key to the problem? After systemctl status mysqld, it shows mysqld is active and running.

Thanks.

jazzi avatar Jun 02 '22 02:06 jazzi

if you install LAMP by this script, default is /tmp/mysql.sock

teddysun avatar Jun 02 '22 03:06 teddysun

Thanks. After exposing the right location of mysql socket by the following command, I still get the same error. Any ideas?

sudo usermod -d /tmp/ mysql

jazzi avatar Jun 02 '22 08:06 jazzi

/var/run/mysqld/mysqld.sock Doesn't look like it was installed by LAMP script. Sorry can not help you, please Google it.

teddysun avatar Jun 02 '22 08:06 teddysun