Service management is a crucial skill for any Linux user. Whether you are just getting started in Linux or have tons of experience, you are going to come across instances where you need to start, stop, or restart a service in your Linux system.
NOTE: This guide is tested on
- MySQL Server - MySQL Server version 8.0
- Linux Distribution - Ubuntu 22.10, 22.04, 20.10, 20.04 and Debian 10, 11
Before running the commands provided in this guide, verify you have your target MySQL Server version installed on your system.
You can view our tutorials on how to install MySQL version 5.0 or 8.0 on Ubuntu, Debian, CentOS, Fedora, and OpenSUSE.
Start, Stop, and Restart MySQL Using system V Init Scripts
One of the most popular ways to manage services in Linux using system v scripts. You can explore our tutorial on system v init scripts to learn more.
To start MySQL using System V Init Script:
sudo service mysqld start
To stop the MySQL Service, run:
sudo service mysqld stop
To restart the Service:
sudo service mysqld restart
Manually Execute the System V Init Scripts
In some cases, your target machine may not have the service command installed. In such as case, you can manually call the startup scripts to start, stop or restart the MySQL Server.
Manually Start MySQL
sudo /etc/init.d/mysqld start
Manually Stop MySQL
sudo /etc/init.d/mysqld stop
Manually Restart MySQL
sudo /etc/init.d/mysqld restart
Start, Stop, and Restart MySQL with Systemd
Finally, we have the popular service management utility:
systemd. We can use the system control utility to manage the services.
Systemd Start MySQL
sudo systemctl start mysqld
Systemd Stop MySQL
sudo systemctl stop mysqld
Systemd Restart MySQL
sudo systemctl restart mysqld
And there you have it!, several methods for starting, stopping, and restarting MySQL Server on Linux systems.