Solution to the Insufficient Disk Space under ubuntu Causing mysql to Be Unable to Start
- 2021-07-18 09:12:18
- OfStack
Preface
You recently added two fields to a single table in your database, Later, it was suggested that there was insufficient disk space. Later, the database was disconnected, and then 1 could not be connected directly. Finally, after thinking, this problem was finally solved. This 1 experience was really frightening. This article is a solution to record that mysql could not start due to insufficient disk space under 1.
The method is as follows
Operating system: ubuntu, mysql cannot be started due to insufficient disk space, which will cause the following problems:
root@iZ28z558vv0Z:/etc/mysql# mysql -u root -p
Enter password:
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)
root@iZ28z558vv0Z:/b# service mysql start
start: Job failed to start
root@iZ28z558vv0Z:/var/lib# service mysqld start
mysqld: unrecognized service
Solution: Locate the mysql configuration file my. cnf:
root@iZ28z558vv0Z:/etc/mysql# ls
conf.d debian.cnf debian-start my.cnf
root@iZ28z558vv0Z:/etc/mysql# vi my.cnf
The item datadir in the file shows/var/lib/mysql
[mysqld]
#
# * Basic Settings
#
user = mysql
pid-file = /var/run/mysqld/mysqld.pid
socket = /var/run/mysqld/mysqld.sock
port = 3306
basedir = /usr
datadir = /var/lib/mysql
tmpdir = /tmp
lc-messages-dir = /usr/share/mysql
skip-external-locking
Because there is not enough disk space, we need to look at the location where mysql saves data, the disk space usage where datadir or tmpdir are located, and the disk space usage where datadir is located:
root@iZ28z558vv0Z:/var# df /var
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/xvda1 41151808 39038392 0 100% /
From the above, it can be seen that the disk space availability rate is 0, which is the reason why mysql cannot be started. Remove other files in the/var directory to free up disk space to fix the problem and restart the mysql service.
Summarize
The above is the whole content of this article. I hope the content of this article can bring 1 certain help to everyone's study or work. If you have any questions, you can leave a message for communication.