MySQL installation differs by operating system, but the core steps are the same: download the installer, run it, choose your settings, and verify the installation works

MySQL is a database system that stores and organizes data for websites and applications. Most people install it either as a standalone server on their own machine or as part of a package like XAMPP or WAMP that bundles MySQL with other tools. The fastest route depends on whether you want just MySQL or a complete development environment.

This guide covers installation on Windows, macOS, and Linux. Each path takes 10 to 20 minutes from download to a working database you can test.

Key Takeaways

  • Download MySQL from mysql.com or use a bundled package like XAMPP if you also need Apache and PHP.
  • Windows users run an .msi installer; macOS users can use a .dmg file or Homebrew; Linux users typically use their system package manager.
  • During installation you set a root password, which is the master account for your MySQL server.
  • After installation, open a command prompt or terminal and run mysql -u root -p to confirm MySQL is working.
  • If you get a "command not found" error, MySQL's bin folder is not in your system path and needs to be added manually.

Installing MySQL on Windows

Go to mysql.com, click Downloads, and select MySQL Community Server. Choose the Windows installer (.msi file) for your system architecture — most modern computers are 64-bit. Run the installer once it finishes downloading.

The installer opens a setup wizard. Click through the license agreement, then choose Setup Type. For a first installation, select Developer Default, which installs MySQL Server, MySQL Workbench (a visual tool for managing databases), and other utilities. Click Next and proceed through the configuration steps.

When prompted for MySQL Server configuration, keep the default port 3306 unless another application is already using it. You will be asked to set a root password — this is the master account for your MySQL server. Write this password down; you will need it to connect to MySQL later. Complete the installation and MySQL Server will start automatically.

Installing MySQL on macOS

macOS users have two main routes: download the installer from mysql.com or use Homebrew, a package manager that handles downloads and setup automatically.

Using the installer: Go to mysql.com, select Downloads, and choose the macOS installer (.dmg file). Open the downloaded file and run the installer package inside. Follow the prompts to set your root password and complete setup. The installer adds MySQL to your system automatically.

Using Homebrew: Open Terminal and run brew install mysql. Homebrew downloads and installs MySQL in one step. After installation completes, run mysql.server start to start the MySQL server. Then run mysql_secure_installation to set a root password and configure security settings. This route is faster if you already use Homebrew for other tools.

Installing MySQL on Linux

Linux installation depends on your distribution. Ubuntu and Debian users open a terminal and run sudo apt update followed by sudo apt install mysql-server. The system package manager downloads and installs MySQL automatically.

After installation, run sudo mysql_secure_installation to set a root password and configure security. When prompted, answer yes to remove anonymous users and disable remote root login — these are security best practices for a local development machine.

For other Linux distributions like CentOS or Fedora, use sudo yum install mysql-server or sudo dnf install mysql-server depending on your system. The steps after installation are the same.

Verifying MySQL is installed and working

After installation completes on any operating system, open a command prompt (Windows) or terminal (macOS and Linux) and type mysql -u root -p. Press Enter, then type the root password you set during installation. If MySQL is working, you will see a mysql> prompt.

Type SHOW DATABASES; and press Enter. You should see a list of default databases like information_schema and mysql. If you see this list, MySQL is installed and running correctly. Type EXIT; to close the connection.

If you get a "command not found" or "mysql is not recognized" error, MySQL's bin folder is not in your system path. On Windows, add the MySQL bin folder (usually C:\Program Files\MySQL\MySQL Server 8.0\bin) to your system environment variables. On macOS and Linux, you may need to use the full path like /usr/local/mysql/bin/mysql -u root -p.

Using a bundled package instead

If you are setting up a development environment and also need Apache (a web server) and PHP (a programming language), consider XAMPP or WAMP instead of installing MySQL alone. These packages bundle MySQL, Apache, and PHP together and handle all the configuration automatically.

XAMPP works on Windows, macOS, and Linux. WAMP is Windows-only. Download from xampp.com or wampserver.com, run the installer, and both MySQL and Apache start with a single click. This route is simpler if you are building a website locally before uploading it to a web host, because your local setup matches what most hosting providers use.

Connecting to MySQL from other applications

Once MySQL is running, other programs can connect to it using the hostname localhost (or 127.0.0.1), port 3306, username root, and the password you set. If you are using MySQL Workbench, click the plus icon next to MySQL Connections, enter these details, and click Test Connection to verify it works.

If you are writing code in Python, PHP, or another language, you will need a MySQL driver or library for that language. Python uses mysql-connector-python or PyMySQL; PHP uses mysqli or PDO. These are separate downloads, but they all connect using the same hostname, port, and password.

Frequently Asked Questions

What is the difference between MySQL Community Server and MySQL Enterprise?

Community Server is free and suitable for development and small production use. Enterprise is a paid version with additional support, monitoring tools, and security features. For learning or personal projects, Community Server is the right choice.

Can I run multiple versions of MySQL on the same computer?

Yes, but they must use different ports. During installation, you can choose a port other than the default 3306. Most people do not need multiple versions unless they are testing compatibility between old and new code.

I forgot my root password. How do I reset it?

On Windows, stop MySQL Server, then restart it with the --skip-grant-tables flag to bypass password checking. Connect without a password, then run FLUSH PRIVILEGES; followed by ALTER USER 'root'@'localhost' IDENTIFIED BY 'newpassword';. On macOS and Linux, the process is similar but requires stopping the service from the command line first.

Do I need to install MySQL if I am using a web hosting provider?

No. Most hosting providers run MySQL on their servers already. You upload your code and connect to their MySQL instance using credentials they provide. You only install MySQL locally if you are developing on your own machine before uploading to a host.

Why does MySQL ask for a root password during installation?

The root account is the administrator account for your MySQL server. Setting a password protects it from unauthorized access. Even on a personal machine, this is a security best practice. Write the password down or store it in a password manager so you do not lose it.