Sarajevo, Bosnia and Herzegovina

[Solved] MYSQL Can’t Start Server: Can’t Create PID File: No Space Left On Device

The error in the /var/log/mysqld is :

Can't start server: can't create PID file: No space left on device MYSQL

If your MySQL can’t restart and the /var/log/mysqld log show you this message, well, most probably you finished your partition space available.

To solve this issue you have to do the following steps:

1) check your partitions with the command:

df -h


this command will output your partitions conf:

Filesystem            Size  Used Avail Use% Mounted on /dev/sda2              58G   53G   0  100% //dev/sda1              99M   12M   83M  13% /boot /dev/sda2              58G   13G   42G  24% /media/sda2

Please notice that the full size of /dev/sda2 partition is 58GB, the used space is 53GB and the available once is 0 (100% use).

2) Now that we are aware of this we have to find the files (often they are huge log files) that fill our partition. So we could take a look in the /var directory or /tmp directory to find and move some of them via rsync into another partition or we could free some space deleting older logs and files not needed. (Be carefully when you are doing that).
To find big files over your system you could execute this command via ssh

du -h --max-depth=3 /* > mybigfiles.txt

This command will write in the file all the output of the command du -h -max-depth=3 in the file named mybigfiles.txt all showing all the dirs in the system with theirs current size.

Navigating through this file you could find which directories are the biggest ones and after that you have to clean them before restarting MySQL server.

First of all do this command via cmd line:

yum clean all

To empty cached sources and packages in your RH distro.

Then if you would like to remove, for example, all the log files in a dir older then 3 days you have to execute the command :

find /var/log/mydirectorywithbigfiles -type f -mtime +3 -exec rm {}

or use this bash script

#!/bin/bash 
find /var/log/mydirectorywithbigfiles -type f -mtime +3 -exec rm {} \;

that use a combo of find command and -exec rm {} that removes all the files inside that dir.

After that please execute again the command to check if you freed up some disk space.

df -h

Filesystem            Size  Used Avail Use% Mounted on
/dev/sda2              58G   13G   42G  24% /
/dev/sda1              99M   12M   83M  13%/boot 
/dev/sda2              58G   13G   42G  24% /media/sda2

Once finished, please restart your Mysqld daemon, via /etc/init.d/mysqld start.

From blogpost : http://hackerstv.blogspot.cz/2011/11/solved-mysql-cant-start-server-cant.html