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-serverI 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 stopMy question is how do I know that the database is stopped? When I run the above command, followed by
sudo mysql -uuser -ppasswordI 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 shutdownand then
ps aux | grep mysqlI 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 mysqlDoes 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 startStop:
sudo /etc/init.d/mysql stopRestart / reload configs:
sudo /etc/init.d/mysql restartCheck 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 shutdownwhere user and password is that for a user with the proper SHUTDOWN privilege
To check that it has been shut down:
ps aux | grep mysqlIf any processes (other than the 'grep' command) show up, it hasn't been shutdown.
4You 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".
3the 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