Start using MySQL

Start and stop the MySQL server

Run the versioned MySQL 8.4 Homebrew service and verify which server release is active before troubleshooting.

The MySQL server is a long-running background process. Clients, including your future application, only work while it runs, so knowing how to start it, stop it, and check it is the foundation for every other lesson.

Start and stop the versioned Homebrew service with:

brew services start [email protected]
brew services stop [email protected]

start does two things: it launches the server now and registers it with launchd, so it starts again automatically after a reboot. stop is the clean way to shut it down — the server flushes its data to disk before exiting. Use it before uninstalling, before restoring data files, or when you want the machine quiet. Prefer it over killing the process.

Check its state before changing passwords or reinstalling anything:

brew services list
Name       Status  User    File
[email protected]  started flavio  ~/Library/LaunchAgents/[email protected]

started in green means the server is up. none means it is not registered, and error means it tried to start and failed — in that case read the MySQL error log before retrying, because starting it again usually reproduces the same failure. The service name also tells you which MySQL release Homebrew is running.

What a stopped server looks like

A client cannot connect while the server is stopped. The error is specific:

ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)

Learn to read this one. It does not mean a wrong password or a missing account — it means nothing is listening at all. When you see it, check brew services list first. The fix is almost always brew services start [email protected], not touching credentials or configuration.

If you need the server only once, without registering it for automatic startup, brew services run [email protected] starts it for the current session and it stays down after a reboot.

Lesson completed

Take this course offline

Get every free book, course edition, and software download.

Get the download library →