How to Stop Mysqld
-
Start/Stop
mysqld
(Aka MySQL Server) in Windows Operating System -
Start/Stop the
mysqld
(Aka MySQL Server) in Linux (Ubuntu 20.04) Operating System - Conclusion
mysqld
is a daemon server program, also known as MySQL Server. It is used to manage the MySQL data directory that has tables and databases.
This tutorial guides you about the various ways that you can use to start, stop, or restart the MySQL Server.
Everyone has to start and stop the mysqld
according to the operating system that they are using. We’ll explore the different approaches to start, stop, and restart the MySQL Server using the Windows and Linux (Ubuntu 20.04) operating systems.
Start/Stop mysqld
(Aka MySQL Server) in Windows Operating System
Method 1 - Using Windows Run Dialogue
You can use Windows Run dialogue if you are using Windows operating system. You can open it by pressing Windows+R. Once it is open, type services.msc
(see attached below) and press OK.
Search for the MySQL##
(Here ##
represents the version). If you have MySQL 8.0, look for MySQL80 on the following screen.
Right now, MySQL Server is running. Right-Click MySQL## (replace ## with your MySQL Version) and select Stop. You can also select pause or restart from here as well.
It will stop the mysqld
(MySQL Server). See the following screenshot.
You can also start, stop, pause, or restart the MySQL Server from the menu bar in services
as follows.
Method 2 - Using Windows Command Prompt
You can also stop your MySQL Server from the command-line if you are comfortable with Windows Command Prompt (also called CMD). Open Command Prompt as an administrator (see the screenshot given below).
It will open a black window and go to the MySQL bin folder C:\Program Files\MySQL\MySQL Server 8.0\bin
.
If you want to confirm whether your MySQL Server is running or not, you can check using the following command. Replace the username
with your username.
Once you type the given command and press enter, it will ask for the password. Enter your password or press the enter key if you don’t have any.
mysqladmin -u [username] -p status
Our MySQL server is currently active; see the following screenshot.
We can stop it and confirm the server’s inactivity in the command line as follows. You can also see it in services.msc
.
-- replace [username] with yours
mysqladmin -u [username] -p shutdown
--check status
mysqladmin -u [username] -p status
You can see the practical use of the commands as follows and notice that we cannot connect after shutting it down.
Start/Stop the mysqld
(Aka MySQL Server) in Linux (Ubuntu 20.04) Operating System
In the Linux operating system, you have different variations of commands to start/stop MySQL Server. This variation depends on what Linux distribution you are using.
We are using Linux (Ubuntu 20.04) for this article.
If you are also a Linux (Ubuntu 20.04) user, you can stop the MySQL Server using the following command and then check the status to confirm. Fedora users can see this documentation, and CentOS commands are very similar to Fedora.
-- if you are logged in as superuser (root user) then use the following commands
systemctl stop mysql
systemctl status mysql
-- if you are not logged in as superuser (root user) then use the following commands
sudo systemctl stop mysql
sudo systemctl status mysql
Use the following command to start the MySQL Server in Ubuntu.
-- if you are logged in as superuser (root user) then use the following commands
systemctl start mysql
systemctl status mysql
-- if you are not logged in as superuser (root user) then use the following commands
sudo systemctl start mysql
sudo systemctl status mysql
-- You can use the following command to make sure that the server launches after reboot
systemctl enable mysql
# OR
sudo systemctl enable mysql
The green dot and text in green represent that your server is up and running (see screenshot given below).
Use the command given below to restart the MySQL server.
-- if you are logged in as superuser (root user) then use the following commands
systemctl restart mysql
systemctl status mysql
-- if you are not logged in as superuser (root user) then use the following commands
sudo systemctl restart mysql
sudo systemctl status mysql
The other way to do it in Ubuntu 20.04 is as follows.
-- if you are logged in as superuser (root user) then use the following commands
service start mysql
service stop mysql
-- if you are not logged in as superuser (root user) then use the following commands
sudo service start mysql
sudo service stop mysql
Conclusion
In this article, we have understood that the mysqld
is also called MySQL Server.
We have different methods to start/stop it depending on the operating system. Furthermore, there is some variation in Linux commands depending on what Linux distribution you are using.