FreeBSD Start / Stop / Restart MySQL Server

by on October 9, 2007 · 11 comments· LAST UPDATED December 27, 2013

in , ,

I am a new FreeBSD version 6.x/7.x/8.x/9.x/10.x server user. How do I start / stop or restart MySQL server from a shell prompt over ssh session?

Tutorial details
DifficultyEasy (rss)
Root privilegesYes
RequirementsNone
Estimated completion time1m
First login as the root user. Next make sure MySQL service is enabled. Just open /etc/rc.conf file using vi text editor:
# vi /etc/rc.conf

Append / modify following line to start MySQL service:
mysql_enable="YES"

Save and close the file.

Task: Start MySQL server on FreeBSD

Type the following command:
# /usr/local/etc/rc.d/mysql-server start

Task: Stop MySQL server on FreeBSD

Type the following command:
# /usr/local/etc/rc.d/mysql-server stop

Task: Restart MySQL server on FreeBSD

Type the following command:
# /usr/local/etc/rc.d/mysql-server stop && /usr/local/etc/rc.d/mysql-server start

TwitterFacebookGoogle+PDF versionFound an error/typo on this page? Help us!

{ 11 comments… read them below or add one }

1 chat October 3, 2008 at 12:31 am

Thank you. i need this command.

Reply

2 GB June 25, 2009 at 5:43 pm

God tip.
Thanks!

Reply

3 KAZEEM ADEDOKUN July 30, 2009 at 5:06 pm

pls. i need more about mySQL method of setting and resetting

Reply

4 Beginner August 20, 2009 at 3:38 pm

Appreciated.

Reply

5 Vorbis January 27, 2010 at 5:20 pm

As always, phenomenal tips from nixcraft. Every single problem I have ever had with freeBSD this site has solved! 5/5

Reply

6 Linux techie May 18, 2010 at 12:48 pm

Very useful info. Could you please tell me how to configure the MySQL server to work with PHP. I have just installed and started.

Reply

7 Rob November 22, 2011 at 1:36 am

I had to add the following to /etc/rc.conf for this to work:

mysql_enable=”YES”
mysql_args=”–user=mysql”

Reply

8 informatty January 30, 2012 at 1:04 pm

Cool! It runned cool for me !

Reply

9 kent December 27, 2013 at 4:55 pm

/usr/local/etc/rc.d/mysql-server restart

Reply

10 Laki September 7, 2014 at 10:13 pm

If you don’t like starting mysql from /usr/local/etc/rc.d/ and service won’t work like this :

# service mysql status
mysql does not exist in /etc/rc.d or the local startup
directories (/usr/local/etc/rc.d)

You can make symlink

ln -s /usr/local/etc/rc.d/mysql-server mysql

This way you can use

# service mysql status
mysql is running as pid 5023.

# service mysql restart
Stopping mysql.
Waiting for PIDS: 5023.
Starting mysql.

Reply

11 Laki September 7, 2014 at 10:14 pm

Assuming you are in /etc/rc.d

Reply

Leave a Comment

Tagged as: , , , , , , ,

Previous Faq:

Next Faq: