Skip to lesson

Install MySQL Server and MySQL Workbench

To run SQL on your own computer you need two things: MySQL Server, the program that stores the data and runs your statements, and a tool to talk to it. This course uses the mysql terminal client, which comes with the server, and MySQL Workbench, a free window-based tool.

Download MySQL 8.4 LTS

An LTS (Long-Term Support) release is a version that gets bug and security fixes for years without changing how it works. MySQL 8.4 is an LTS release, so it is a safe version to learn on.

MySQL comes in two kinds of release. An LTS (Long-Term Support) release, such as 8.4, gets bug and security fixes for years without changing how things work. Innovation releases (9.x) add features every few months. Install 8.4 LTS: it is what most companies run, and everything in this section works on it.

Open the MySQL Community Downloads page at dev.mysql.com/downloads in your browser. You need two downloads from it: MySQL Community Server and MySQL Workbench. Both are free. When the site offers "Login" or "Sign Up", click No thanks, just start my download below them; no account is needed.

On Windows, download the MSI Installer (a .msi file). On macOS, download the DMG Archive that matches your chip: ARM, 64-bit for Apple Silicon (M1 to M4) or x86, 64-bit for an Intel Mac. Apple menu → About This Mac shows which you have. Download MySQL Workbench for your system in the same way.

Linux is not covered step by step. Install the mysql-server package of your distribution, or follow the MySQL APT or Yum repository guide on the same downloads site.

Run the installer: the root password and port 3306

root is the built-in administrator account of MySQL: it can do everything on the server. You choose its password during installation, and you use it only to set things up.

During setup you choose a password for root, the built-in administrator account that can do everything on the server. Pick one you will remember and write it down somewhere safe; you type it every time you connect, and it cannot be shown again later.

A port is a numbered door on a computer that one server program listens on, so requests reach the right program. MySQL listens on port 3306 by default. Keep 3306 unless the installer says it is already in use.

On Windows, open the .msi and choose the Typical setup; the MySQL Configurator then asks for the port, the root password and a service name (keep MySQL84). On macOS, run the .pkg inside the .dmg and keep Use Strong Password Encryption. The server runs in the background: as a Windows service, or from System Settings → MySQL on macOS.

  1. Run the installer you downloaded and click through the pages with the default choices.
  2. When it asks for the root password, type one you will remember and write it down.
  3. Keep port 3306 and let the server start when the installation finishes.
  4. Install MySQL Workbench from its own download (on macOS, drag it into Applications).

Add the mysql client to your PATH

PATH is the list of folders your terminal searches when you type a command name. Adding the MySQL bin folder to it lets you type mysql from any folder.

PATH is a list of folders your terminal searches when you type a command name. The installer puts the mysql client in a folder that is usually not on that list, so typing mysql gives "not recognized" or "command not found" until you add the folder.

You do this once. After it, mysql works from any folder in any new terminal window.

The folder to add is C:\Program Files\MySQL\MySQL Server 8.4\bin on Windows and /usr/local/mysql/bin on macOS.

  1. Windows: press the Windows key, search for environment variables, open Environment Variables, select Path under User variables, click New and paste the folder.
  2. macOS: run echo 'export PATH="/usr/local/mysql/bin:$PATH"' >> ~/.zshrc, then source ~/.zshrc.
  3. Close every terminal window and open a new one, so it reads the new PATH.

Check the install with mysql --version and Workbench

mysql --version prints the client's version and proves that PATH works. Then mysql -u root -p connects to the server as root (-u is the user, -p means "ask me for the password"), which proves the server is running and the password is right.

Example 1 · Check the client version

Terminal
mysql --version
Sample output
C:\Program Files\MySQL\MySQL Server 8.4\bin\mysql.exe  Ver 8.4.6 for Win64 on x86_64 (MySQL Community Server - GPL)

What this code does

  • Any 8.4.x number is fine; the last digit grows with each bug-fix release. On Windows the line may start with just mysql instead of the full path. On a Mac it starts with mysql Ver 8.4.6 for macos15 on arm64 (or x86_64 on an Intel Mac).
  • If you see "not recognized" or "command not found" instead, the PATH step is not done yet, or the terminal was opened before it.

Example 2 · Connect as root and ask the server its version

Terminal
mysql -u root -pSELECT VERSION();exit
Sample output
Enter password: ********
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 9
Server version: 8.4.6 MySQL Community Server - GPL

Copyright (c) 2000, 2025, Oracle and/or its affiliates.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> SELECT VERSION();
+-----------+
| VERSION() |
+-----------+
| 8.4.6     |
+-----------+
1 row in set (0.00 sec)

mysql> exit
Bye

What this code does

  • Type the first line in the terminal. The password is not shown while you type it, not even as dots on some computers; type it and press Enter. The next two lines are typed at the mysql> prompt.
  • The welcome text, connection id and timing differ on your computer. What matters is that you reach mysql> and VERSION() starts with 8.4.

When the prompt changes to mysql>, you are talking to the server. Type SELECT VERSION(); and press Enter; the server answers with its version. Type exit to leave.

In Workbench, the home screen usually shows a box for your local server, named something like Local instance MySQL84 or Local instance 3306. Click it, type the root password, and a query tab opens. If the box is missing, click the + next to "MySQL Connections" and keep host 127.0.0.1, port 3306, user root.

Order of execution

Check your install in order

Put the checks in the order you run them in a new terminal.

When the check fails

Almost every install problem shows one of four messages. Each one points at one cause, so read the message before trying anything else.

Example 3 · The server is not running

Terminal
mysql -u root -p
Sample output
Enter password: ********
ERROR 2003 (HY000): Can't connect to MySQL server on 'localhost:3306' (10061)

What this code does

  • This is the Windows message: nothing is listening on port 3306, so the server is stopped. On macOS the same problem prints ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2).
  • Start the server as shown for your computer in the section above, then run the command again. A wrong password gives error 1045 instead, which means the server is running.

To start a stopped server, open Services on Windows, right-click MySQL84 and choose Start (or run net start MySQL84 in a Command Prompt opened as administrator). On macOS, open System Settings → MySQL and click Start MySQL Server.

  • not recognized (Windows) or command not found: mysql (macOS): PATH is missing the bin folder, or the terminal was opened before you changed it.
  • ERROR 1045 (28000): Access denied for user 'root'@'localhost': the password is wrong. Passwords are case-sensitive.
  • ERROR 2003 (HY000): Can't connect to MySQL server on 'localhost:3306' (Windows) or ERROR 2002 (HY000) (macOS): the server is not running.
  • Port 3306 is already in use during setup: another MySQL (often from XAMPP or an old install) is running. Stop it, or choose 3307 and connect with -P 3307.

Predict the output

Read the message

What does this connection attempt tell you?

mysql -u root -p
Enter password: ********
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)

Next step

Check your understanding

10 quick questions