×


Job for mariadb.service failed because the control process exited with error code - How to fix it ?

Sometimes, in the process of starting the installation of MariaDB on your CentOS 8 system,  you can fail to start the MariaDB services on your system. 

This error happens when there is an issue with the MariaDB installation.

Here at LinuxAPT, as part of our Server Management Services, we regularly help our Customers to perform MariaDB related errors.

In this context, we will look into how to resolve this MariaDB error.


Nature of MariaDB error "Job for mariadb.service failed because the control process exited with error code" ?

When this error occurs, you will see an error message such as this:

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

You will observe the above error when you try to start the MariaDB services on your system by running the below-given commands:

$ sudo systemctl start mariadb.service
$ sudo systemctl status mariadb.service


How to fix MariaDB error "Job for mariadb.service failed because the control process exited with error code" ?

To resolve the above-mentioned problem, you need to implement some set of commands on the terminal. 

i. Navigate into the data directories and list all files by using the following commands:

$ cd /var/lib/mysql
$ ls

ii. Remove all data from the directories.

$ rm -r *

iii. Again initialize the database directory by running the following command:

$ mysql_install_db --user=mysql --basedir=/usr --datadir=/var/lib/mysql

iv. Start the mysqld by executing the following commands:

$ sudo systemctl start mysqld

v. Now, again start the MariaDB and msql service.

$ sudo systemctl start mysql.service
$ sudo systemctl start mariadb.service

You need to authenticate the user login password. Enter the password.


vi. To get the service status run the below-given command:

$ sudo systemctl status mariadb.service


[Need urgent assistance to fix MariaDB related errors? We are available to help you today. ]


Conclusion

This article covers how to resolve the above maiadb problem "Job for mariadb.service failed because the control process exited with error code" which may arise during the installation of #MariaDB on #CentOS 8.

The /var/lib/mysql directory is not empty when MariaDB is installed, it contains e.g. the 'mysql' database and some other files. 

Recreating the folder, even with correct permissions, will not help you. 

Either MariaDB has not been successfully installed or the directory was removed. Reinstall MariaDB to get a working basic database system back.

Also, you can give access /var/log/mysql/* to mysql by running the command:

sudo chown mysql:mysql /var/log/mysql/*


MariaDB offers more and better storage engines, NoSQL support, provided by Cassandra, allows you to run SQL and NoSQL in a single database system. 

MariaDB also supports TokuDB, which can handle big data for large organizations and corporate users.


To view mysql error logs:

1. edit /etc/my.cnf [mysqld] log=/tmp/mysql.log.

2. restart the computer or the mysqld service service mysqld restart.

3. open phpmyadmin/any application that uses mysql/mysql console and run a query.

4. cat /tmp/mysql.log ( you should see the query )