The error message "Failed to start MariaDB.service: Unit not found" encountered while attempting to start MariaDB on a CentOS 7 system suggests that the MariaDB service is not properly installed or configured. This article provides a step-by-step guide on how to address this issue.
Causes of the Problem
- Incomplete or Incorrect Installation: MariaDB was not fully or correctly installed.
- Incorrect System Configuration: The system link to the mariadb.service is missing or corrupted.
- Version Conflicts: Multiple versions of MySQL or MariaDB are installed on the system, causing conflicts.
Solution
Step 1: Verify MariaDB Installation
The first step is to verify that MariaDB is correctly installed on your system.
- Run the command
yum list installed | grep mariadb
to check if MariaDB is installed. - If MariaDB is not installed, install it using the command
sudo yum install mariadb-server
.
Step 2: Start the MariaDB Service
After verifying or installing MariaDB, it is necessary to start the service and enable it for automatic startup.
- Run
sudo systemctl start mariadb
to attempt to start the service. - Use
sudo systemctl enable mariadb
to set the MariaDB service to start automatically upon system boot.
Step 3: Check Service Status
Verify that the MariaDB service is running without issues.
- Run
sudo systemctl status mariadb
to check the status of the service.
Step 4: Configure MariaDB
After successfully starting the service, it is recommended to perform basic configuration.
- Run
sudo mysql_secure_installation
for security configuration, such as setting the root password and removing anonymous users.
Step 5: Resolve Version Conflict Issues
If you have multiple versions of MySQL or MariaDB installed on the system, conflicts may occur.
- Remove old or unnecessary versions using
sudo yum remove mysql* mariadb*
. - Reinstall the desired version of MariaDB.
Conclusion
The error message "Failed to start mariadb.service: Unit not found" typically indicates issues with the installation or configuration of MariaDB on CentOS 7. Follow the above steps to resolve this problem. It is important to note that proper installation and configuration of database systems are crucial for ensuring their reliable and secure operation.