MySQL server is not working

Hello,

When I try to start MYSQL I have this error :

### Failed to start database :

Job for mysql.service failed because the control process exited with error code. See "systemctl status mysql.service" and "journalctl -xe" for details.

And this is logs :

[ubuntu@vps~]# /etc/init.d/mysql stop
Stopping mysql (via systemctl): mysql.service.
[ubuntu@vps-f80251d6 ~]# killall -KILL mysql mysqld_safe mysqld
sh: 1: killall: not found
[ubuntu@vps~]# /etc/init.d/mysql start
Starting mysql (via systemctl): mysql.serviceJob for mysql.service failed because the control process exited with error code.
See "systemctl status mysql.service" and "journalctl -xe" for details.
 failed!
[ubuntu@vps~]# systemctl status mysql.service
● mysql.service - MySQL Community Server
     Loaded: loaded (/lib/systemd/system/mysql.service; enabled; vendor preset: enabled)
     Active: failed (Result: exit-code) since Tue 2022-02-08 14:45:43 UTC; 8s ago
    Process: 215306 ExecStartPre=/usr/share/mysql/mysql-systemd-start pre (code=exited, status=0/SUCCESS)
    Process: 215321 ExecStart=/usr/sbin/mysqld (code=exited, status=1/FAILURE)
   Main PID: 215321 (code=exited, status=1/FAILURE)
     Status: "Server startup in progress"

Feb 08 14:45:43 vps-f80251d6 systemd[1]: mysql.service: Main process exited, code=exited, status=1/FAILURE
Feb 08 14:45:43 vps-f80251d6 systemd[1]: mysql.service: Failed with result 'exit-code'.
Feb 08 14:45:43 vps-f80251d6 systemd[1]: Failed to start MySQL Community Server.
Feb 08 14:45:43 vps-f80251d6 systemd[1]: mysql.service: Scheduled restart job, restart counter is at 5.
Feb 08 14:45:43 vps-f80251d6 systemd[1]: Stopped MySQL Community Server.
Feb 08 14:45:43 vps-f80251d6 systemd[1]: mysql.service: Start request repeated too quickly.
Feb 08 14:45:43 vps-f80251d6 systemd[1]: mysql.service: Failed with result 'exit-code'.
Feb 08 14:45:43 vps-f80251d6 systemd[1]: Failed to start MySQL Community Server.
[ubuntu@vps~]# journalctl -xe
sh: 1: journalctl: not found

Any idea what is the issue ? And what I can do to solve ?

Thank you

You need to look at the mysql log in /var/log.

The journal may also have something useful (you definitely have journalctl, don’t just give up because it’s not in the non-root user PATH).

Is this a new VPS build? Has it ever worked? If it did work at some point, have you upgraded anything e.g. cnf file or other configs? If never worked how was mysql installed?

A bit more background would be useful.

It’s a new VPS yes, honestly I can’t remember if it worked, but I do think yes, but I am not sure. In any way, I never use it on this server.
I removed days ago some mysql bin log files in /var/lib/mysql folder, because it was using all space on my VPS. Not sure if this can cause that issue.

I can’t understand much more :frowning: can you ?


2022-02-10T07:45:43.583140Z 0 [System] [MY-010910] [Server] /usr/sbin/mysqld: Shutdown complete (mysqld 8.0.28-0ubuntu0.20.04.3)  (Ubuntu).
2022-02-10T07:45:44.547331Z 0 [System] [MY-010116] [Server] /usr/sbin/mysqld (mysqld 8.0.28-0ubuntu0.20.04.3) starting as process 589834
2022-02-10T07:45:44.570730Z 1 [ERROR] [MY-011011] [Server] Failed to find valid data directory.
2022-02-10T07:45:44.570860Z 0 [ERROR] [MY-010020] [Server] Data Dictionary initialization failed.
2022-02-10T07:45:44.570909Z 0 [ERROR] [MY-010119] [Server] Aborting
2022-02-10T07:45:44.571358Z 0 [System] [MY-010910] [Server] /usr/sbin/mysqld: Shutdown complete (mysqld 8.0.28-0ubuntu0.20.04.3)  (Ubuntu).

That’s the issue, you can’t just delete those files.

1 Like

Anyway to solve ?

If it is a new VPS, the easiest way to fix this is to reinstall it completely … and never delete/modify anything again in /var/lib/mysql : MySQL hates when one messes up with its files :wink:

Yes, that is a no no. Server can get seriously irritated if you delete those files. You have to purge them instead. If you have a backup, I would restore locally if that is an option, purge then upload to online server. If not, you have to start clean again.

Ok, then I will rebuilt it from scratch. Then question, I had issues with those binlog files getting too much in size, like 19Gb, while my server is 20Gb. How can I block this ?

Is there automated way to purge ?

SQL is my kryptonite, so I just leave it to do what it does, but Googling ‘mysql purge bin log’ did produce quite a few results so it should be doable.

It shouldn’t do that. You probably had an exploitable web app running.

It’s a fresh new server with latest versions

Edit the file /etc/mysql/my.cnf

Find a line that reads “log_bin” and remove or comment it as follows:

#log_bin = /var/log/mysql/mysql-bin.log

You also need to remove or comment following lines:

#expire_logs_days = 10

#max_binlog_size = 500M

Close and save the file. Restart mysql server:

# service mysql restart

1 Like

If you don’t plan to use MySQL’s binary logs, you can just disable them by adding…

skip-log-bin

… in the [mysqld] part of the config file.

Before you do that, make sure to Google a bit in order to fully understand what binary logs are.

1 Like

This topic was automatically closed 8 days after the last reply. New replies are no longer allowed.