✓ Solved

MySQL Failed to Start in Debian 12

Hi,

I just did a fresh install of mysql 8.0.34 (had to jump through some hoops), but now the service won't start. I don't understand the journalctl message. It's not very descriptive. How can I troubleshoot this?

I've enabled it "sudo systemctl enable mysql.service", but it won't start. Thanks for any guidance you can provide.

Here's my sudo systemctl status mysql.service output:

× mysql.service - MySQL Community Server
     Loaded: loaded (/lib/systemd/system/mysql.service; enabled; preset: enabled)
     Active: failed (Result: exit-code) since Tue 2023-08-15 17:32:00 UTC; 52min ago
       Docs: man:mysqld(8)
             http://dev.mysql.com/doc/refman/en/using-systemd.html
    Process: 29212 ExecStartPre=/usr/share/mysql-8.0/mysql-systemd-start pre (code=exited, status=0/SUCCESS)
    Process: 29247 ExecStart=/usr/sbin/mysqld (code=exited, status=1/FAILURE)
   Main PID: 29247 (code=exited, status=1/FAILURE)
     Status: "Server shutdown complete"
      Error: 22 (Invalid argument)
        CPU: 1.604s

Aug 15 17:31:57 localhost systemd[1]: Starting mysql.service - MySQL Community Server...
Aug 15 17:32:00 localhost systemd[1]: mysql.service: Main process exited, code=exited, status=1/FAILURE
Aug 15 17:32:00 localhost systemd[1]: mysql.service: Failed with result 'exit-code'.
Aug 15 17:32:00 localhost systemd[1]: Failed to start mysql.service - MySQL Community Server.
Aug 15 17:32:00 localhost systemd[1]: mysql.service: Consumed 1.604s CPU time.

2 Replies

✓ Best Answer

It looks like I had a corrupted ibdata1 file. I found this after reading the /var/log/mysql/error.log. I ended up executing the following steps:

sudo apt purge mysql-server
sudo rm -rf /var/lib/mysql*
sudo apt install mysql-server
sudo systemctl start mysql.service

The lib/ files were restored when the service started.

I'm glad to hear you figured this out! I'd like to offer some workarounds I found in this reddit post in case others have issues with Debian 12 and MySQL not playing well together. Despite the unhelpful snark in the comments, I do think some of the suggestions may help.

The first is to use something already compatible with Debian 12, like MariaDB.

Next, rather than try to make MySQL work directly with Debian 12, you could try to first set up Docker on your server. You can then get a Docker Image of MySQL, which may help prevent the error from occurring, though I can't say for sure. Here are some guides to help if you'd like to try to that route:

After playing around with MySQL on Debian 12 for a bit, you've gotten further than I have, so I can't provide advice for getting past that error, but I had no trouble with either of those workarounds. Hopefully one of those works for you, or someone else sees this who has figured out how to make Debian 12 and MySQL more compatible.

Reply

Please enter an answer
Tips:

You can mention users to notify them: @username

You can use Markdown to format your question. For more examples see the Markdown Cheatsheet.

> I’m a blockquote.

I’m a blockquote.

[I'm a link] (https://www.google.com)

I'm a link

**I am bold** I am bold

*I am italicized* I am italicized

Community Code of Conduct