FB

Do you want to know how to start, stop, and restart the MySQL server? Learn how you can do that on each operating system in this article.

MySQL on Mac

To start MySQL on Mac, you can use the command line. The commands you use depend on which version of MySQL you have: either before 5.7 or 5.7 and newer.

Version 5.7 came out in October 2015, so if you’ve downloaded it anytime in the last few years it’s most likely after 5.7.

Newer than 5.7

For MySQL version 5.7 and newer, open the Terminal and run the launchctl command.

Start MySQL server:

sudo launchctl load -F /Library/LaunchDaemons/com.oracle.oss.mysql.mysqld.plist

Stop MySQL server:

sudo launchctl unload -F /Library/LaunchDaemons/com.oracle.oss.mysql.mysqld.plist

 

Older than 5.7

If you’re running a version of MySQL older than 5.7, your commands are slightly different.

Start MySQL server:

sudo /usr/local/mysql/support-files/mysql.server start

Stop MySQL server:

sudo /usr/local/mysql/support-files/mysql.server stop

Restart MySQL server:

sudo /usr/local/mysql/support-files/mysql.server restart

 

MySQL on Windows

If you’re running MySQL on Windows, you can either use the Command Line or the Services section in the Control Panel.

Command Line

To start or stop MySQL on the Windows command line:

Open the Command Line by finding it in the Start menu or pressing the Windows key and searching for “command”.

Enter the following commands to start or stop MySQL:

Start MySQL server:

mysqld

If that command does not work, it’s because the folder that this tool is located is not in your Windows PATH environment variable. You can run MySQL using this command instead (substituting the 8.0 folder with the folder for the MySQL version you’re using):

"C:\Program Files\MySQL\MySQL Server 8.0\bin\mysqld"

Stop MySQL server:

"C:\Program Files\MySQL\MySQL Server 8.0\bin\mysqladmin" -u root shutdown

You should substitute the 8.0 folder with the folder for the MySQL version you’re using.

 

Services in Control Panel

Alternatively, you can use the Services section in Windows to start, stop, and restart MySQL server.

To do this:

  1. Press the Windows key to open the Start menu and allow searching.
  2. Type “services.msc”
  3. Press Enter, and the Services window will open.
  4. Search for the MySQL service
  5. Click Start, Stop, or Restart to perform the related action for MySQL.

 

MySQL on Linux

If you’re running MySQL on Linux, you can start, stop, or restart MySQL using the command line.

You can use one of several different commands to do this.

Start MySQL server:

/etc/init.d/mysqld start

Or

service mysqld start

Or

service mysql start

 

Stop MySQL server:

/etc/init.d/mysqld stop

Or

service mysqld stop

Or

service mysql stop

 

Restart MySQL server:

/etc/init.d/mysqld restart

Or

service mysqld restart

Or

service mysql restart

 

Conclusion

So there are a few different ways to start, stop, and restart MySQL on each operating system. They all support a command line method, and the commands are slightly different.