After installing mariadb-server on CentOS 7, you might encounter a situation where neither mysqld nor mysql.server commands are available, despite the packages showing as installed. This typically occurs due to path and service naming differences between MySQL and MariaDB.
First, verify what's actually installed:
# Check installed MariaDB packages
yum list installed | grep maria
# Expected output:
# mariadb.x86_64 1:5.5.37-1.el7_0 @updates
# mariadb-libs.x86_64 1:5.5.37-1.el7_0 @updates
# mariadb-server.x86_64 1:5.5.37-1.el7_0 @updates
MariaDB uses different service names than MySQL. Instead of mysqld, the service is named mariadb:
# Correct way to start the service
systemctl start mariadb
# Enable automatic startup on boot
systemctl enable mariadb
The main server binary is typically installed at:
/usr/libexec/mysqld
You can verify this with:
find / -name mysqld 2>/dev/null
If you prefer using the traditional service command:
service mariadb start
Or using the safe wrapper:
/usr/bin/mysqld_safe --datadir=/var/lib/mysql
After starting the service, check its status:
systemctl status mariadb
# Or using traditional methods
service mariadb status
Don't forget to run the security script:
mysql_secure_installation
This will guide you through setting root password, removing anonymous users, and other security measures.
- Confusing MySQL and MariaDB service names
- Not checking for existing MySQL installations that might conflict
- Permission issues with /var/lib/mysql directory
- SELinux blocking the service
If you're still having issues, check the logs:
journalctl -xe
tail -f /var/log/mariadb/mariadb.log
I recently encountered a puzzling situation after installing MariaDB on a fresh CentOS 7 droplet on Digital Ocean. While the packages appeared to be installed correctly, I couldn't find the essential server components - mysqld
and mysql.server
- anywhere in the system.
First, let's verify what's actually installed:
[root@hostname ~]# yum list installed | grep maria
mariadb.x86_64 1:5.5.37-1.el7_0 @updates
mariadb-libs.x86_64 1:5.5.37-1.el7_0 @updates
mariadb-server.x86_64 1:5.5.37-1.el7_0 @updates
The client tools are present and accounted for:
[root@hostname ~]# which mysql
/bin/mysql
Attempting to start the service reveals our core problem:
[root@hostname ~]# service mysqld start
Redirecting to /bin/systemctl start mysqld.service
Failed to issue method call: Unit mysqld.service failed to load: No such file or directory.
[root@hostname ~]# mysqld
-bash: mysqld: command not found
[root@hostname ~]# mysql.server start
-bash: mysql.server: command not found
A directory listing shows many MySQL/MariaDB utilities but no server binary:
[root@hostname ~]# ls -la /bin/my* | grep mysqld
-rwxr-xr-x 1 root root 24558 Jun 24 10:24 /bin/mysqld_multi
-rwxr-xr-x 1 root root 27313 Jun 24 10:24 /bin/mysqld_safe
The key realization here is that MariaDB uses different service names than MySQL. Instead of mysqld
, we should use:
[root@hostname ~]# systemctl start mariadb.service
To enable automatic startup on boot:
[root@hostname ~]# systemctl enable mariadb.service
After starting the service, verify it's running:
[root@hostname ~]# systemctl status mariadb.service
● mariadb.service - MariaDB database server
Loaded: loaded (/usr/lib/systemd/system/mariadb.service; enabled; vendor preset: disabled)
Active: active (running) since Wed 2023-09-13 14:23:45 UTC; 5min ago
If the service still doesn't work, verify the installation completed properly:
[root@hostname ~]# rpm -ql mariadb-server
/usr/lib/systemd/system/mariadb.service
/usr/lib/systemd/system/mariadb@.service
/usr/bin/mysqld_safe
[...]
After getting the service running, don't forget to secure your installation:
[root@hostname ~]# mysql_secure_installation
This will guide you through setting a root password, removing anonymous users, disabling remote root login, and removing test databases.