teddysun / lamp

Install LAMP (Linux + Apache + MySQL/MariaDB + PHP) for AlmaLinux/RockyLinux/CentOS/Debian/Ubuntu

Home Page:https://lamp.sh

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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

jazzi opened this issue · comments

commented

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.

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

commented

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

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