• We value your experience with Plesk during 2024
    Plesk strives to perform even better in 2025. To help us improve further, please answer a few questions about your experience with Plesk Obsidian 2024.
    Please take this short survey:

    https://pt-research.typeform.com/to/AmZvSXkx
  • The Horde webmail has been deprecated. Its complete removal is scheduled for April 2025. For details and recommended actions, see the Feature and Deprecation Plan.

Issue DB query failed: SQLSTATE[HY000] [2002] Connection refused

my.cnf is located in /etc/mysql/ and this is the content:

Code:
# The MariaDB configuration file
#
# The MariaDB/MySQL tools read configuration files in the following order:
# 1. "/etc/mysql/mariadb.cnf" (this file) to set global defaults,
# 2. "/etc/mysql/conf.d/*.cnf" to set global options.
# 3. "/etc/mysql/mariadb.conf.d/*.cnf" to set MariaDB-only options.
# 4. "~/.my.cnf" to set user-specific options.
#
# If the same option is defined multiple times, the last one will apply.
#
# One can use all long options that the program supports.
# Run program with --help to get a list of available options and with
# --print-defaults to see which it would actually understand and use.

#
# This group is read both both by the client and the server
# use it for options that affect everything
#
[client-server]

# Import all .cnf files from configuration directory
!includedir /etc/mysql/conf.d/
!includedir /etc/mysql/mariadb.conf.d/
[mysqld]
bind-address = ::ffff:127.0.0.1
local-infile=0

I had also tried adding skip-grant-tables, as suggested in several threads, but with no results
 
Yeah, I just forgot you are using Debian.

You could try creating the sock file manually:

Code:
mkdir /var/run/mysqld
touch /var/run/mysqld/mysqld.sock
chown -R mysql:mysql /var/run/mysqld
cannot create directory ‘/var/run/mysqld’: File exists
I ran 2 more commands,
now try to reboot?
 
This is not the same issue as the other user. SQLSTATE[HY000] [2002] Connection refused just means that plesk coudn't connect to the database, usually because the database server is not running because it crashed. But that is just a symptom; the underlying error is very different.
You could try creating the sock file manually:

Code:
mkdir /var/run/mysqld
touch /var/run/mysqld/mysqld.sock
chown -R mysql:mysql /var/run/mysqld
Don't do that. systemd will not like it. If there's any problem with the socket file permissions and/or location, edit the systemd unit file. systemd will create that directory when the service is started and remove it when the service is stopped. (I learned that the hard way when I duplicated a redis unit file and did not change the socket directory, resulting in the two services killing each other's socket file ...)

That is not the problem here, though: The socket will only be there while mysqld is running. And touching a file that is supposed to be a socket will not help you anyway because that will create a regular file, which is not useful.

Jan 20 10:25:05 apparire.it mysqld[76770]: 2022-01-20 10:25:05 139675451006336 [Warning] Can't create test file /var/lib/mysql/apparire.lower-test
And this is why it refuses to start.
Check the permissions on /var/lib/mysql, check whether there is enough space in the filesystem (df ; df -i).
Did you restore or copy to the /var/lib/mysql directory and did not preserve owner and permission information? If it is a restore from another machine, the owner might be wrong.
Let's have a look at ls -l /var/lib/mysql before you try chown -R mysql:mysql /var/lib/mysqld.
 
This is not the same issue as the other user. SQLSTATE[HY000] [2002] Connection refused just means that plesk coudn't connect to the database, usually because the database server is not running because it crashed. But that is just a symptom; the underlying error is very different.

Don't do that. systemd will not like it. If there's any problem with the socket file permissions and/or location, edit the systemd unit file. systemd will create that directory when the service is started and remove it when the service is stopped. (I learned that the hard way when I duplicated a redis unit file and did not change the socket directory, resulting in the two services killing each other's socket file ...)

That is not the problem here, though: The socket will only be there while mysqld is running. And touching a file that is supposed to be a socket will not help you anyway because that will create a regular file, which is not useful.


And this is why it refuses to start.
Check the permissions on /var/lib/mysql, check whether there is enough space in the filesystem (df ; df -i).
Did you restore or copy to the /var/lib/mysql directory and did not preserve owner and permission information? If it is a restore from another machine, the owner might be wrong.
Let's have a look at ls -l /var/lib/mysql before you try chown -R mysql:mysql /var/lib/mysqld.
cd: /var/lib/mysql: No such file or directory

Code:
df -i

Filesystem                 Inodes  IUsed   IFree IUse% Mounted on
udev                       498928    324  498604    1% /dev
tmpfs                      501857    490  501367    1% /run
/dev/mapper/vg01--vg-root 7572096 704477 6867619   10% /
tmpfs                      501857      1  501856    1% /dev/shm
tmpfs                      501857      7  501850    1% /run/lock
tmpfs                      501857     15  501842    1% /sys/fs/cgroup
/dev/sda2                   62496    331   62165    1% /boot
/dev/sda1                       0      0       0     - /boot/efi
tmpfs                      501857     11  501846    1% /run/user/0

Not a restore from another machine.
 
cd: /var/lib/mysql: No such file or directory
That is bad. It means you have no database. Even on a fresh install, the directory should exist. So someone or -thing must have removed it.
I hope you have backups.

... just checking: Did that server ever run at all, or are you still in the setting-up stage?
 
just checking: Did that server ever run at all, or are you still in the setting-up stage?
Has been a production site for several years, I've dumps of the databases made with phpmyadmin of the most important domain. Other files I've already concerning wordpress istance, have downloaded yesterday.

I have no idea what happened but I saw that it is a problem that has happened to others in the last period.

On Tuesday I updated plesk, I renewed the Plesk Wordpress Toolkit license and cloned the WordPress instance of one domain on subdomain staging.
Then suddenly I no longer had access to the Plesk panel but only to the repair window where a problem was highlighted to mariadb not starting.
Disk space doesn't seem to be the problem.
Now I don't even access the repair window anymore because it doesn't recognize the admin password.
I've root access only!
 
Back
Top