Solution to mysql failure to start due to insufficient disk space in ubuntu

Solution to mysql failure to start due to insufficient disk space in ubuntu

Preface

Recently, I added two fields to a table in the database. Later, it prompted something like insufficient disk space. Then the database was disconnected, and I couldn't connect to it after that. Later, after thinking about it, I finally solved the problem. This experience was really terrifying. This article records the solution to the problem of mysql being unable to start due to insufficient disk space.

Here’s how

Operating system: Ubuntu. Insufficient disk space causes MySQL to fail to start, which can 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: Find 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 datadir item 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 the disk space is insufficient, we need to check the location where MySQL saves data, the usage of the disk space of datadir or tmpdir, and check the usage of the disk space of datadir:

root@iZ28z558vv0Z:/var# df /var
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/xvda1 41151808 39038392 0 100% /

It can be seen from the above that the disk space availability is obviously 0, which is why mysql cannot be started. The problem can be solved by deleting other files in the /var directory to free up disk space, and then restarting the mysql service.

Summarize

The above is the full content of this article. I hope that the content of this article can be of some help to your study or work. If you have any questions, you can leave a message to communicate.

You may also be interested in:
  • MySQL uses frm files and ibd files to restore table data
  • MySQL export of entire or single table data
  • Solve the problem that the MySQL database crashes unexpectedly, causing the table data file to be damaged and unable to start
  • Why the disk space is not released after deleting data in MySQL
  • Common problems with the MySQL storage engine MyISAM (table corruption, inaccessibility, insufficient disk space)
  • How to turn off MySQL log to protect disk space under lnmp
  • Several suggestions for shrinking MySQL to save disk space
  • How to free up disk space after deleting data in Mysql InnoDB
  • Why is the disk space still occupied after deleting table data in MySQL?

<<:  JS implements click drop effect

>>:  How to isolate users in docker containers

Recommend

Unzipped version of MYSQL installation and encountered errors and solutions

1 Installation Download the corresponding unzippe...

Tutorial on configuring and using i3 window manager in Linux

In this article, I will show you how to install a...

Vue implements sample code to disable browser from remembering password function

Find information Some methods found on the Intern...

CSS polar coordinates example code

Preface The project has requirements for charts, ...

Vue axios interceptor commonly used repeated request cancellation

introduction The previous article introduced the ...

MySQL explain obtains query instruction information principle and example

explain is used to obtain query execution plan in...

Analysis of MySQL's method of exporting to Excel

This article describes how to use MySQL to export...

Record the whole process of MySQL master-slave configuration based on Linux

mysql master-slave configuration 1. Preparation H...

Two methods to stretch the background image of a web page

There are two solutions: One is CSS, using backgro...

How to uninstall Linux's native openjdk and install sun jdk

See: https://www.jb51.net/article/112612.htm Chec...

Common solutions for Mysql read-write separation expiration

The pitfalls of MySQL read-write separation The m...