FreeBSD Start / Stop / Restart MySQL Server

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

ADVERTISEMENTS

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

🐧 Get the latest tutorials on SysAdmin, Linux/Unix, Open Source/DevOps topics:
CategoryList of Unix and Linux commands
File Managementcat
FirewallCentOS 8 OpenSUSE RHEL 8 Ubuntu 16.04 Ubuntu 18.04 Ubuntu 20.04
Network Utilitiesdig host ip nmap
OpenVPNCentOS 7 CentOS 8 Debian 10 Debian 8/9 Ubuntu 18.04 Ubuntu 20.04
Package Managerapk apt
Processes Managementbg chroot cron disown fg jobs killall kill pidof pstree pwdx time
Searchinggrep whereis which
User Informationgroups id lastcomm last lid/libuser-lid logname members users whoami who w
WireGuard VPNCentOS 8 Debian 10 Firewall Ubuntu 20.04

ADVERTISEMENTS
11 comments… add one
  • chat Oct 3, 2008 @ 0:31

    Thank you. i need this command.

  • GB Jun 25, 2009 @ 17:43

    God tip.
    Thanks!

  • KAZEEM ADEDOKUN Jul 30, 2009 @ 17:06

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

  • Beginner Aug 20, 2009 @ 15:38

    Appreciated.

  • Vorbis Jan 27, 2010 @ 17:20

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

  • Linux techie May 18, 2010 @ 12:48

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

  • Rob Nov 22, 2011 @ 1:36

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

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

  • informatty Jan 30, 2012 @ 13:04

    Cool! It runned cool for me !

  • kent Dec 27, 2013 @ 16:55

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

  • Laki Sep 7, 2014 @ 22:13

    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.

  • Laki Sep 7, 2014 @ 22:14

    Assuming you are in /etc/rc.d

Leave a Reply

Your email address will not be published.

Use HTML <pre>...</pre>, <code>...</code> and <kbd>...</kbd> for code samples.