Celeb Glow
general | March 08, 2026

How to restart MySQL?

I am running MySQL 5.1.54 and installed it on Ubuntu through the terminal using the command

sudo apt-get install mysql-server

I changed the my.cnf file and would like to stop and then start the database. I've tried the following

sudo /usr/bin/mysqld_safe stop

My question is how do I know that the database is stopped? When I run the above command, followed by

sudo mysql -uuser -ppassword

I can log right back into the database. Shouldn't it tell me that the database is not running?

EDIT:I've also tried

mysqladmin -uuser -ppassword shutdown

and then

ps aux | grep mysql

I get the following output

david 12093 0.0 0.0 6052 1276 pts/1 T May10 0:00 nano /etc/mysql/my.cnf
root 12267 0.0 0.0 6396 1436 pts/1 T May10 0:00 sudo nano /etc/mysql/my.cnf
root 12269 0.0 0.0 6052 1388 pts/1 T May10 0:00 nano /etc/mysql/my.cnf
mysql 15371 0.3 0.1 55344 9088 ? Ssl 10:53 0:00 /usr/sbin/mysqld
david 15512 0.0 0.0 5304 864 pts/1 R+ 10:54 0:00 grep --color=auto mysql

Does the above output mean that MySQL has been shut down? If I run mysql -uuser -ppassword I can still log into MySQL.

6 Answers

You should really use the Sys-V init scripts located in /etc/init.d.

Start:

sudo /etc/init.d/mysql start

Stop:

sudo /etc/init.d/mysql stop

Restart / reload configs:

sudo /etc/init.d/mysql restart

Check run status:

sudo /etc/init.d/mysql status
8

In Ubuntu machines, you can restart the mysql using both commands :

 1. sudo /etc/init.d/mysql restart 2. # service mysql restart
1

To shutdown mysql, run:

mysqladmin -uuser -ppassword shutdown

where user and password is that for a user with the proper SHUTDOWN privilege

To check that it has been shut down:

ps aux | grep mysql

If any processes (other than the 'grep' command) show up, it hasn't been shutdown.

4

You can use kill -9 "PID" command to do that, the MySQL Process ID (PID) you can get running ps -a or top commands. Then you can start it again by calling ./"main process".

3

the systemctl utility available by default in used to manage services in your linux box. it can be used to start, restart and stop services. There are other options you can use. checkout systemctl ?

systemctl stop mysql
systemctl start mysql
1

use the following command to restart mysql

 # mysql start/stop/restart # MAC $ cd /path/mysql/bin $ mysql.server restart #Linux $ /etc/init.d/mysqld restart or $ service mysqld restart or $ systemctl restart mysqld

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy