FreeBSD Start / Stop / Restart MySQL Server

last updated in Categories , ,

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?

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:

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


Posted by: Vivek Gite

The author is the creator of nixCraft and a seasoned sysadmin, DevOps engineer, and a trainer for the Linux operating system/Unix shell scripting. Get the latest tutorials on SysAdmin, Linux/Unix and open source topics via RSS/XML feed or weekly email newsletter.

11 comment

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

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

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


  4. 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.

    Still, have a question? Get help on our forum!