In this tutorial, you will learn how to start, restart and stop MySQL Server on CentOS 8.
Check MySQL Server Status
On CentOS 8 you can check MySQL Server running status with following command:
$ systemctl status mysqld
The output will be like followings if MySQL Server is not start up.
● mysqld.service - MySQL 8.0 database server
Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled; vendor preset: disabled)
Active: inactive (dead) since Wed 2021-03-31 05:39:51 UTC; 20s ago
Process: 179628 ExecStopPost=/usr/libexec/mysql-wait-stop (code=exited, status=0/SUCCESS)
Process: 179582 ExecStartPost=/usr/libexec/mysql-check-upgrade (code=exited, status=0/SUCCESS)
Process: 179537 ExecStart=/usr/libexec/mysqld --basedir=/usr (code=exited, status=0/SUCCESS)
Process: 179500 ExecStartPre=/usr/libexec/mysql-prepare-db-dir mysqld.service (code=exited, status=0/SUCCESS)
Process: 179475 ExecStartPre=/usr/libexec/mysql-check-socket (code=exited, status=0/SUCCESS)
Main PID: 179537 (code=exited, status=0/SUCCESS)
Status: "Server shutdown complete"
Start MySQL Server
To start MySQL Server with following command:
$ sudo systemctl start mysqld
There are no output information after running the start command if everything is ok, you can check the running status of MySQL Server by running following command:
$ sudo systemctl status mysqld
Stop MySQL Server
To stop MySQL Server, use command:
$ sudo systemctl stop mysqld
Restart MySQL Server
To restart MySQL Server, use command:
$ sudo systemctl restart mysqld
Summary
You can manage MySQL Server not only with the systemd
(systemctl
) command but also commands using service
and init.d
.
$ sudo service mysql start
$ sudo /etc/init.d/mysql start