Linux – How to restart MySQL

linuxMySQLUbuntu

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?

Any suggestions? Thank you.

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.

Any suggestions?

Best Answer

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
Related Question