MariaDB (MySQL) Won't Start on Ubuntu Server: The Definitive Solution

It is a quite common problem for a MariaDB (or MySQL) service running on Ubuntu to suddenly fail to start.
In this article, I will explain in detail how to apply a definitive and permanent solution, especially when encountering the following error:

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

Error Details

When the service fails to start, the following errors usually appear when examining /var/log/mysql/error.log or via journalctl:

Can't lock aria control file '/home/mysql/aria_log_control'
InnoDB: Unable to lock ./ibdata1 error: 11
Plugin 'InnoDB' registration as a STORAGE ENGINE failed.

These errors occur because MariaDB was started by a previous process and was not shut down completely. Since the database engine sees the relevant control files (e.g., aria_log_control, ibdata1) as locked, it cannot open a new session, and the service cannot be started.

Step-by-Step Definitive Solution

You can follow the steps below to resolve this issue:

  1. Kill all MariaDB/MySQL processes:
    sudo pkill -f mariadbd
    sudo pkill -f mysqld
    sudo pkill -f mysql

    These commands forcibly terminate all related processes running in memory.

  2. Check processes after cleanup:
    ps aux | grep -i mysql

    Only the grep output should appear here. If there are other lines, the processes might still be running.

  3. Restart the MariaDB service:
    sudo systemctl start mariadb
  4. Verify the service status:
    sudo systemctl status mariadb

    If it says active (running), MariaDB has been started successfully.

  5. Test logging into the MySQL session:
    mysql -u root -p

    If you reach the MariaDB [(none)]> screen after entering your password, it means everything is working normally.

Additional Information

The root of this problem is often a MariaDB process running in the background that was left open accidentally or closed incorrectly. Because this process keeps the database files locked, a new session cannot be started. When these processes are terminated via manual intervention, the system continues to operate normally.

Conclusion

Although MariaDB failing to start on an Ubuntu server seems serious, it is a problem that can be completely solved with a few simple terminal commands. By following the steps above, you can restart the service healthily and restore your system without data loss.

Was this answer helpful?