MySQL and MariaDB are both popular yet similar open-source relational database management systems. This is because MariaDB is a fork of MySQL. As such, managing either is a similar experience and process.
There are a few ways that MySQL and MariaDB services can be managed in Linux, though systemd is the popular choice. Other alternatives are using SysVinit and service command, though, on most Linux systems, these are available alongside systemd.
Some primary management tasks for MySQL and MariaDB are to start, stop and restart the service. You can also set MySQL and MariaDB to either automatically start or not during system boot. All these can be managed via systemd using the systemctl command.
$ sudo systemctl status mysql [sudo] password for user: ● mysql.service - MySQL Community Server Loaded: loaded (/lib/systemd/system/mysql.service; enabled; preset: enable> Active: active (running) since Tue 2023-02-07 08:39:17 +08; 37min ago Process: 866 ExecStartPre=/usr/share/mysql/mysql-systemd-start pre (code=ex> Main PID: 1068 (mysqld) Status: "Server is operational" Tasks: 38 (limit: 2225) Memory: 360.7M CPU: 4.988s CGroup: /system.slice/mysql.service └─1068 /usr/sbin/mysqld Feb 07 08:39:16 host systemd: Starting MySQL Community Server... Feb 07 08:39:17 host systemd: Started MySQL Community Server.
MariaDB also uses mysql for service name, though mariadb service is also available and can be used.
Replace mysql with mysqld for RedHat-based platforms.
$ sudo systemctl stop mysql
$ sudo systemctl start mysql
$ sudo systemctl restart mysql
$ sudo systemctl disable mysql Synchronizing state of mysql.service with SysV service script with /lib/systemd/systemd-sysv-install. Executing: /lib/systemd/systemd-sysv-install disable mysql Removed "/etc/systemd/system/multi-user.target.wants/mysql.service".
$ sudo systemctl enable mysql Synchronizing state of mysql.service with SysV service script with /lib/systemd/systemd-sysv-install. Executing: /lib/systemd/systemd-sysv-install enable mysql Created symlink /etc/systemd/system/multi-user.target.wants/mysql.service → /lib/systemd/system/mysql.service.
Comment anonymously. Login not required.