Wednesday, February 1, 2023

MySQL fails to start when a Plesk server lacks disk space: SQLSTATE[HY000] No space left on device 500 Plesk\Exception\Database

 Symptoms:

When opening Plesk or exporting/importing a database in Plesk, the operation fails with one of the following error messages:

ERROR: Plesk\Exception\Database
DB query failed: SQLSTATE[HY000]: General error: 1021 Disk full (/var/tmp/#sql_3b95_1); waiting for someone to free some space..., <...>

Server Error
500 Plesk\Exception\Database
DB query failed: SQLSTATE[HY000]: General error: 1 Can't create/write to file '/var/tmp/#sql_9d1_0.MAI' (Errcode: 28), <...>

Server Error
500
Zend_Db_Adapter_Exception
SQLSTATE[HY000][2002] No such file or directory


This page isn’t working
203.0.113.2 is currently unable to handle this request.
HTTP ERROR 500


The MySQL service fails to start with the "No space left on device" error in its status:


# systemctl status mariadb.service

systemd[1]: Starting MariaDB database server...
systemd[1]: mariadb.service failed to run 'start-pre' task: No space left on device
systemd[1]: Failed to start MariaDB database server.
systemd[1]: mariadb.service failed


Cause:

# df -hT

Filesystem Size Used Avail Use% Mounted on
/dev/sda3 50G 50G 20K 100% /

Or

#df -i

Filesystem Inodes IUsed IFree IUse% Mounted on
tmpfs 483902 1 483901 1% /dev/shm
/dev/sda3 3276800 3276800 0 100% /


Resolution:


Remove the unwanted files in /tmp and /var/tmp

# find /var/tmp -type f -mtime +14 -exec rm {} \;

# find /tmp -type f -mtime +14 -exec rm {} \;