How to start/stop MySQL server on Linux
By Angsuman Chakraborty, Gaea News NetworkFriday, January 7, 2005
# To Start MySQL Server
/sbin/service mysqld start
# To Stop MySQL Server
/sbin/service mysqld stop
# To Restart MySQL Server
/sbin/service mysqld restart
And of course there is the brute force way to kill all the processes:
$ for i in `ps -ef |grep mysqld |awk ‘{print $2}’`; do `kill -9 $i`; done
Thanks to Anthony Eden for the comment (below) to remove the dot in front.
A simpler alternative is:
pkill mysqld
This will kill the mysqld process. However the best way to stop (because it stops properly) is obviously:
/sbin/service mysqld stop
vahith |
March 6, 2010: 2:41 pm
while start the mysql it show error msg 2000 (can’t connect the local server /var/lib/mysql/mysql.sock…) tell what is the procedure to start the mysql |
anon |
June 13, 2009: 6:14 pm
Some Linux distros to start use # /etc/init.d/mysqld start to stop use (note: use the whole directory) |
dyana |
February 17, 2009: 9:55 am
can someone help me, |
December 1, 2008: 10:17 pm
What we have to do if we are using My SQL first time in linux machine. I have started My SQL services. |
Paul M |
June 11, 2008: 5:20 am
Really this should be titled How to Stop Mysql Server on Redhat/Fedora. /sbin/service is a redhat-ism. Its basically a wrapper script around the init.d scripts. Debian/Ubuntu users, and other based on SysV style init scripts (most I think maybe not SuSE) can do the same thing by invoking /etc/init.d/mysql stop as root which is what /sbin/service does. |
Sanford |
November 27, 2007: 8:22 pm
No difference. The name of the mysqld executive may vary from one distribution to another and even between versions. On fedora core 6 it is mysqld. Which distro are you using? |
November 27, 2007: 3:26 pm
Got the way. “service mysql stop” worked fine. |
November 27, 2007: 3:19 pm
I tried /sbin/service mysqld stop |
prasanna |
October 18, 2007: 5:06 am
I tried the above one, but not able to stop! |
April 2, 2007: 7:48 am
You can also try these: |
hari |
March 31, 2007: 5:49 am
hai angsuman ..well the tip you provided to start the SQL server isnt working . |
bhanu |
February 2, 2005: 5:20 am
Ortwin, Very true. killall can be used instead of the awkward awk code. I missed it because it is not on my Linux installation provided by my hosting provider. Thanks for the tip. Angsuman |
Ortwin Glück |
January 8, 2005: 12:21 pm
I suggest you remove the . in front of the first slash so that you can execute that command from anywhere, not just in the / directory. |
Bhas