How to start/stop MySQL server on Linux

By Angsuman Chakraborty, Gaea News Network
Friday, 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

Filed under: Database, Linux, RDBMS, Web Hosting

July 17, 2010: 3:31 am

Thanks for the Mysql commands on force stop

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

January 11, 2010: 9:24 am

thx for the info

June 13, 2009: 6:14 pm

Some Linux distros to start use

# /etc/init.d/mysqld start
# mysqld_safe &
press or mysql

to stop use
# /etc/init.d/mysqld stop

(note: use the whole directory)

February 17, 2009: 9:55 am

can someone help me,
i did installed mysql5 on fedora7,
the problem now is i couldn’t run it,
i did tried to use the command been given here
but still starting mysql failed

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.

August 28, 2008: 11:28 pm

Use the following command to find mysqld:
locate mysqld

August 26, 2008: 7:54 pm

Where to get this mysqld ? I cannot find it.

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.

November 29, 2007: 7:48 pm

Worked like a charm, many thanks!

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.
But, please clarify the difference. I don’t know what is the difference.

November 27, 2007: 3:19 pm

I tried /sbin/service mysqld stop
But faled. got response “mysqld: unrecognized service

October 18, 2007: 1:14 pm

To stop just use:
service mysqld stop

October 18, 2007: 5:06 am

service mysqld start
service mysqld stop
service mysqld restart

I tried the above one, but not able to stop!

April 2, 2007: 7:48 am

You can also try these:
service mysqld start
service mysqld stop
service mysqld restart

March 31, 2007: 5:49 am

hai angsuman ..well the tip you provided to start the SQL server isnt working .

February 2, 2005: 5:20 am


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.


Ortwin Glück
February 2, 2005: 4:41 am

what about
# killall mysqld

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.

will not be displayed