Hoppa till huvudinnehållet

How to Install MySQL: Guide for Windows, macOS, and Linux

Learn how to install MySQL on Windows, macOS, and Linux. Configure your server, secure it properly, and verify the installation step by step.
16 juni 2026  · 15 min läsa

Although MySQL functions the same across the board, the installation process varies slightly depending on your operating system. Windows, macOS, and Linux each have their own installation methods and configuration steps.

In this guide, I will show you how to install MySQL on your preferred operating system, perform basic configuration, verify that the server is running correctly, and troubleshoot common installation issues along the way.

If you are a bit unfamiliar with SQL, try our very popular, well-designed, and comprehensive Introduction to SQL course to get started.

Before Installing MySQL

Before I begin showing you the installation process, make sure your system meets these basic requirements for running MySQL. First, check that you have sufficient disk space and memory for optimal performance. You will also need administrator or root privileges on your computer to install the software and configure system services.

When choosing a version, download the latest stable General Availability (GA) release (currently MySQL 8.0 or 8.x). It includes the core database server and tools needed for development and production environments.

MySQL is available in two main editions:

  • MySQL Community Edition: A free, open-source version suitable for most developers, students, and organizations.
  • MySQL Enterprise Edition: A commercial version that includes advanced security, monitoring, backup, and support features for enterprise environments.

How to Install MySQL on Windows

Installing MySQL on Windows is straightforward when using the official MySQL Installer. Follow the steps below to download, install, and configure MySQL Server.

Download MySQL Installer

To download the MySQL Installer:

  1. Open your web browser and visit the official MySQL Downloads page.
  2. Select MySQL Installer for Windows.
  3. Choose one of the available installer packages:

MySQL Installer download

You will be presented with two download options for the Windows MSI Installer:

  • Web installer: This is a small download that retrieves the required MySQL components during installation. It is a lightweight download (around 2-5 MB) and downloads only the components you select. It requires an active internet connection during setup.
  • Full Installer: This is a larger download (around 400+ MB) that includes all the available MySQL tools and products. It can be installed without an internet connection.

Run the Installer

After downloading the file:

  1. Locate the downloaded installer file.
  2. Double-click the installer to launch the setup wizard.
  3. If prompted by Windows User Account Control (UAC), click Yes to grant administrator privileges.
  4. Allow the installer to perform any required prerequisite checks.

During setup, MySQL Installer opens, displaying the Choosing a Setup Type screen. 

Choosing Setup Type MySQL

Select the option that best fits your development needs from:

Setup Type

Decsription

When to Use

Developer/Full (default)

This option installs MySQL Server, MySQL Workbench, MySQL Shell, connectors and development tools, documentation, and additional utilities

When you plan to build applications using MySQL, or want a complete development environment.

Server only

This option installs only the MySQL Server component.

If the computer will act primarily as a database server, or if you do not need graphical tools or development utilities

Client only

This option installs client tools only.

Use it when you have systems that connect to existing servers

Custom

Allows you to manually select exactly which products, documentation, and versions you want to install.

When you want specific MySQL products, or you need to control installation locations, or you want to minimize disk usage

As a beginner, I recommend you choose Developer/Full and proceed with these steps:

  1. Click Next. Review the products that will be installed.
  2. Click Execute to download and install the selected components.

Installation of MySQL

  1. Wait for all installation tasks to complete successfully.

MySQL products installation

  1. Click Next when prompted.

Configure MySQL Server

After installation, the MySQL Configuration Wizard launches automatically. Follow the steps below to begin modifying your server settings:

Step 1: Configure Server Type and Networking

  1. Leave this as a Development Computer to use a conservative amount of memory so it doesn't slow down your personal machine. Click Next.
  2. Since MySQL listens for connections through a network port, leave TCP/IP Networking enabled.
  3. Keep the default port value: 3306
  4. Leave the X Protocol port at its default value unless your environment requires a different configuration.
  5. Click Next.

Configure Type and Networking MySQL

Step 2: Choose an Authentication Method

In the next step, you'll be asked to select an authentication method where:

  • Use Strong Password Encryption (Recommended) is more secure, recommended for new applications, and is compatible with current MySQL clients.
  • Use Legacy Authentication Method is intended for older applications that do not support newer authentication methods. Use this method only if required for compatibility reasons.

Configure Authentication Method MySQL

Step 3: Set the root password

The root account is the administrative account for MySQL.

  1. Enter a strong password for the root user.
  2. Confirm the password.
  3. Store the password securely.
  4. Optionally create additional MySQL user accounts if needed.
  5. Click Next.

Set root password MySQL

Step 4: Configure the Windows Service

MySQL can run automatically as a Windows service. This allows the database to start automatically whenever Windows boots. Use the steps below to set up this service:

  1. Enable Configure MySQL Server as a Windows Service.
  2. Keep the default service name unless your environment requires a different name.
  3. Select Start the MySQL Server at System Startup.
  4. Leave the recommended account settings unchanged unless instructed otherwise.
  5. Click Next.

Configure Windows Service MySQL

Step 5: Configure Server File Permissions

Allow the default permissions to let MySQL set strict server file permissions to protect your data.

Configure Server File Permissions MySQL

Step 6: Apply configuration

On the Apply Configuration screen, you will see a checklist of actions. 

  1. Click Execute.
  2. The installer will apply your settings one by one. Once finished, click Finish.

Apply configuration MySQL

Complete installation

After configuration is finished:

  • Click Next through any remaining setup screens.
  • Click Finish to exit the installer.

MySQL Server is now installed and running on your Windows system.

To confirm if MySQL was installed successfully:

  • Open Command Prompt.
  • Run the following command:
mysql -u root -p

Enter the Root Password you created during setup.

If successful, your command prompt will change to a mysql> prompt.

To verify the server installation, run:

SELECT VERSION();

You should see the installed MySQL version returned in the results.

How to Install MySQL on macOS

You can install MySQL on macOS using either the official DMG package from MySQL or using Homebrew.

Install using the MySQL DMG package

To install using the DMG package, download the installer using the steps below:

  1. Visit the official MySQL Downloads page.
  2. Select the macOS DMG installer for the latest stable version.
  3. Download the package that matches your Mac's architecture (Apple Silicon or Intel).

Run the package by doing the following:

  1. Open the downloaded .dmg file.

  2. Double-click the .pkg installer.

  3. Follow the installation wizard.

  4. Enter your macOS administrator password when prompted.

During installation, the installer may ask you to configure a root password or initialize the server. When the installation finishes, MySQL Server will be installed and available on your system.

Install using Homebrew

Homebrew is a popular package manager for macOS that simplifies software installation from the command line. Follow the steps below to install MySQL using this method.

  1. Open your Terminal application and run the following command to download and install the latest stable version of MySQL:
brew install mysql
  1. Run the command below to start the service and configure it to run automatically in the background:
brew services start mysql

Verify installation

If you want to verify whether the installation was successful:

  1. Open your Terminal and type the following command to securely configure your server.
mysql_secure_installation
  1. Once configured, connect to your MySQL instance.
mysql -u root -p
  1. Type your root password. When the mysql> prompt appears, check your installation status by executing:
SELECT version();

How to Install MySQL on Linux

The installation steps for MySQL vary slightly by Linux distribution. In the examples below, I will cover the most common Linux families.

Ubuntu and Debian

Ubuntu and Debian use the Advanced Package Tool (apt) to download and manage system software. Follow the steps below if you use these distributions:

  1. Update the Local Package Index: Before installing any new software, refresh your local repository lists to get the newest versions:
sudo apt update
  1. Install the MySQL Server Package: Install the official MySQL server package by executing:
sudo apt install mysql-server -y
  1. Start and enable the service: Verify MySQL is running and set to launch automatically whenever your Linux machine boots up:
sudo systemctl start mysql
sudo systemctl enable mysql

CentOS, Rocky Linux, and RHEL

The Red Hat-based enterprise distributions rely on the dnf (or older yum) package manager.

  1. Set up the repository and download MySQL: To install official MySQL, download and enable the official MySQL community release package:
sudo dnf install https://dev.mysql.com/get/mysql80-community-release-el9-1.noarch.rpm -y

If you are using an older version like RHEL 8 or Rocky Linux 8, replace el9 in the URL above with el8.

  1. Install the MySQL package: Disable the default OS-provided database modules and explicitly install the official community server:
sudo dnf module disable mysql -y
sudo dnf install mysql-community-server -y
  1. Start the service: Fire up your newly installed database daemon and configure it to stay operational on system reboots:
sudo systemctl start mysqld
sudo systemctl enable mysqld

Verify installation

To verify a successful installation, check the service status and confirm that the database service is actively running without errors by executing:

sudo systemctl status mysql    # On Ubuntu/Debian
sudo systemctl status mysqld   # On CentOS/Rocky/RHEL

Then check the software version by running a quick build check right from the command line:

mysql --version

How to Secure a New MySQL Installation

After you have installed MySQL, it's important to secure the server before using it in development or production environments. The default installation may include settings and accounts that are convenient for setup, but not ideal from a security perspective.

To close these security gaps, MySQL provides a built-in security utility called mysql_secure_installation. This tool allows you to secure the system through a guided, step-by-step terminal script.

To initialize this tool, open a terminal or command prompt and run:

mysql_secure_installation

The script will prompt you to review and apply several security settings.

Securing the root account

If you haven't already set a password for the administrative root user, the script will prompt you to create one. It will also ask if you want to enable the Validate Password Component.

Remove anonymous users

Some MySQL installations create anonymous user accounts that allow connections without a username. These anonymous accounts present a security risk because they can allow unauthorized access. During the security script, select Yes when asked to remove anonymous users.

Disable remote root access

By default, the root administrative account should be accessible only locally (on the machine running the server). If you allow the root account to connect remotely, it increases the risk of unauthorized access and brute-force attacks. When prompted by mysql_secure_installation, choose “Yes” to disallow remote root logins.

Remove the test database

During installation, MySQL automatically creates a database named test that anyone can access. This is unnecessary for a functioning server. While it is useful for experimentation, it is unnecessary in most environments. When prompted, remove the test database and associated permissions.

Reload privilege tables

After applying security changes, MySQL reloads its privilege tables so the new settings take effect immediately. If prompted, choose Yes to reload privileges.

How to Verify MySQL Installation

As we saw in the example above, you should always verify that MySQL is installed correctly, regardless of whether you are using Windows, macOS, or Linux. The following are ways to get MySQL running correctly.

Start and stop MySQL

You may occasionally need to manually start or stop the MySQL service.

If you are using Windows, open the Command Prompt.

To start MySQL, run: 

net start MySQL80

To stop MySQL, run:

net stop MySQL80

If you are using macOS (Homebrew), open the terminal.

To start MySQL, run:

brew services start mysql

To stop MySQL, run:

brew services stop mysql

If you are on Linux (Ubuntu/Debian), open the terminal.

To start MySQL, run:

sudo systemctl start mysql

To stop MySQL, run:

sudo systemctl stop mysql

To check service status:

sudo systemctl status mysql

Check the installed version

After you have verified the system is up, now verify the installation by checking the MySQL version. Open a terminal or command prompt and run:

mysql --version

If version information is displayed, the MySQL client is installed correctly. For example:

Check MySQL installed version

Connect using the MySQL client

To connect to the server using the MySQL command-line client, run:

mysql -u root -p

Enter your root password when prompted. If the connection succeeds, you'll see the MySQL prompt, mysql>.

This confirms that the MySQL server is accepting connections.

Run a simple query

Once connected, you can execute a simple query to verify that the database engine is functioning properly.

For example, you can run the following query to check the MySQL version:

SELECT VERSION(); 

Check MySQL installed version

To list the available databases, run:

SHOW DATABASES; 

Show databases in MySQL

To exit the MySQL client, run:

EXIT;

Installing MySQL Workbench

MySQL Workbench is the official graphical user interface (GUI) application for MySQL. It provides a user-friendly interface for working with MySQL databases without relying entirely on command-line tools.

MySQL Workbench helps you create and manage databases, run SQL queries, design database schemas, manage users and permissions, monitor server activity, and import/export data.

Although MySQL Workbench is optional, I highly recommend it for beginners and developers who prefer a visual interface.

How to install MySQL Workbench on Windows

If you selected Developer Default during MySQL installation, MySQL Workbench is installed automatically.

If it is not installed, follow the steps below:

  1. Download MySQL Workbench from the MySQL Downloads page
  2. Run the installer.
  3. Follow the installation wizard.
  4. Complete the setup.

How to install MySQL Workbench on macOS

If using the official MySQL installer, download the MySQL Workbench package separately and install it using the provided DMG file.

If using Homebrew, run the command below:

brew install --cask mysqlworkbench

How to install MySQL Workbench on Linux

If you are using Ubuntu or Debian, run the query below:

sudo apt update
sudo apt install mysql-workbench

Connect to a Local MySQL Server

After launching MySQL Workbench:

  1. Click the + icon next to MySQL Connections.

Connect to a local server MySQL

  1. Enter a connection name such as Local MySQL.
  2. Set the hostname to: localhost
  3. Keep the default port: 3306
  4. Enter the username: root
  5. Click Test Connection.

Connect to a local server MySQL

  1. Enter your MySQL password when prompted.
  2. Save the connection.

If the test succeeds, double-click the connection to connect to your MySQL server in Workbench.

Connect to local server MySQL

Common Installation Problems and Fixes

Although installing MySQL is straightforward, you may occasionally encounter issues. Below are some common problems and how to fix them.

Port 3306 already in use

The problem occurs when the installer fails to start and shows an error message that port 3306 is blocked or that the server refuses to bind to it. This usually means another database instance, like an older MySQL install or a MariaDB/XAMPP stack, is already using it.

To fix the issue, identify the process using port 3306, then stop the conflicting application if appropriate. Alternatively, you can configure MySQL to use a different port, such as 3307. 

The MySQL service won't start

This problem occurs when the MySQL service stops immediately after starting. The service startup may fail, or the server status remains offline or stuck in a “starting” loop.

To fix this, check the configuration file errors, existing port conflicts, corrupted data directories, or the available disk space. I also recommend you review MySQL error logs for detailed information about the failure.

Forgotten root password

This is a problem where you cannot log in because you misplaced or forgot the root password. 

To solve the problem, reset the root password using MySQL's password recovery procedure for your operating system. The general steps are as follows:

  1. Stop the MySQL service.
  2. Start MySQL in recovery mode.
  3. Connect without normal authentication.
  4. Set a new root password.
  5. Restart MySQL normally.

Authentication errors

This problem occurs when an older development framework or GUI client fails to connect to your fresh MySQL 8.x server, throwing an authentication plugin error. The probable cause is that MySQL 8.0 uses advanced password encryption that older clients don't understand. 

To solve the problem, you can downgrade the root user's authentication method to the legacy format by logging into the MySQL terminal and running the query below:

ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'your_password';
FLUSH PRIVILEGES;

MySQL Community Edition vs. MySQL Enterprise

As we learned earlier, MySQL is available in both Community and Enterprise editions. The table below summarizes the difference between the two to help you choose the right one depending on your requirements, budget, and support needs.

Feature

Community Edition

Enterprise Edition

Cost

Free

Commercial subscription

Source Code

Open source

Commercial offering

Monitoring Tools

Basic

MySQL Enterprise Monitor and 

Backup Features

Standard options

Enterprise backup tools

Security Features

Standard user privileges and firewall configurations.

Advanced external authentication (LDAP/Active Directory), TDE encryption, and data masking.

Technical Support

Self-taught via community forums, documentation, and Stack Overflow.

24/7 Oracle Premier Support with direct access to MySQL engineers.

What to Do After Installing MySQL

Now that your MySQL server is installed, configured, and secured, the next step is learning how to use it effectively. I recommend trying the following tasks to help you become familiar with MySQL and build a solid foundation for future projects.

Create your first database

By default, MySQL provides system-level databases after configuration. You can create your database for project practice. Log in to your MySQL client and run:

-- Create employees database 
CREATE DATABASE employees;
USE employees;

Design and create tables

Databases store data inside structured tables. You can practice by defining columns and their data types, such as integers, text, and dates. For example, create a simple user directory:

-- Create users table
CREATE TABLE users (
    id INT AUTO_INCREMENT PRIMARY KEY,
    username VARCHAR(50) NOT NULL,
    email VARCHAR(100),
    created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);

The MySQL Basics Cheat Sheet will be a handy reference for common SQL queries as you build queries to filter data and aggregate tables.

Learn basic SQL queries

Now that you have created your table, familiarize yourself with core CRUD operations (Create, Read, Update, Delete) to manipulate and retrieve the data. For example, focus on the commonly used SQL statements such as :

  • SELECT for retrieving data

  • INSERT for adding records

  • UPDATE for modifying data

  • DELETE for removing data

  • CREATE for creating database objects

Check out our SQL Order of Execution tutorial to learn how to write optimized queries and understand how query execution is different from the order of writing.

Connect MySQL to applications

Most real-world MySQL usage involves connecting databases to applications. Try connecting your local MySQL server to a backend language or framework of your choice, such as Node.js, Python/Django, PHP, or Java. You will need to supply your database hostname (127.0.0.1), the port (3306), your database user (root or a custom user), and the password.

Install GUI tools

As we saw earlier, graphical tools such as MySQL Workbench, DBeaver, and TablePlus can simplify database administration and development. These GUI tools can help you browse databases visually, execute queries, manage users, design schemas, import and export data.

Best Practices for Managing MySQL Locally

Whether you are using MySQL for learning, development, or personal projects, following a few best practices can improve security, reliability, and performance:

  • Use strong passwords: Always protect administrative and user accounts with strong passwords. Local environments can still be exposed if malicious scripts execute on your machine or if you connect to insecure public Wi-Fi networks.
  • Keep MySQL updated: MySQL updates often include security fixes, bug fixes, performance improvements, and new features. Check for updates every few months to keep your server and GUI clients up to date with the latest stable builds.
  • Back up your databases: Backups protect you from accidental deletions, corruption, hardware failures, and other unexpected issues. Always verify that backups can be restored and that backup files are securely stored.
  • Monitor service status: Periodically verify that the MySQL service is running correctly. Always monitor for unexpected service stoppages, connection issues, resource usage, and error log messages. If you regularly check the service status, it will help you identify problems before they affect your applications.

Conclusion

Installing MySQL is a straightforward process once you understand the steps for your operating system, whether you're using Windows, macOS, or Linux. After installation, take the time to verify that the server is running correctly, configure it properly, and secure it using recommended practices such as setting a strong root password and removing unnecessary default accounts.

Now you're ready to start practicing SQL! Take our Database Design course, where you will learn to create and manage databases, including granting users access and assigning roles.


Allan Ouko's photo
Author
Allan Ouko
LinkedIn
Data Science Technical Writer with hands-on experience in data analytics, business intelligence, and data science. I write practical, industry-focused content on SQL, Python, Power BI, Databricks, and data engineering, grounded in real-world analytics work. My writing bridges technical depth and business impact, helping professionals turn data into confident decisions.

FAQs

What operating systems support MySQL?

MySQL supports Windows, macOS, Linux, and several Unix-based operating systems.

Is MySQL free to use?

Yes, MySQL Community Edition is free and open-source. MySQL Enterprise Edition requires a paid subscription for advanced features.

What is the default MySQL port?

MySQL uses port 3306 by default for client-server communication.

How do I verify that MySQL is installed correctly?

You can check the installed version, connect using the MySQL client, and run a simple query such as SELECT VERSION();

What is MySQL Workbench used for?

MySQL Workbench is a graphical tool for managing databases, running queries, designing schemas, and administering MySQL servers.

Ämnen

Learn with DataCamp

course

Introduction to Databases in Python

4 timmar
101.3K
In this course, you'll learn the basics of relational databases and how to interact with them.
Se detaljerRight Arrow
Starta kursen
Se merRight Arrow
Släkt

tutorial

How to Set Up and Configure MySQL in Docker

Learn how to set up and configure MySQL database inside Docker containers. The tutorial includes concepts such as connecting to MySQL servers, running MySQL clients to connect to containers, and so on.
Bex Tuychiev's photo

Bex Tuychiev

tutorial

MySQL in Python Tutorial: Getting Started

In this tutorial, you'll learn how to install MySQL, create databases, and create tables, along with much more.
Kurtis Pykes 's photo

Kurtis Pykes

tutorial

How to Install PostgreSQL on Windows and Mac OS X

In this tutorial, you will learn how to install PostgreSQL on two different operating systems - Windows and Mac.
Sayak Paul's photo

Sayak Paul

tutorial

How to Install SQL Server

In this tutorial, you will learn how to install SQL Server on a Windows operating system with a brief introduction to SQL in general.
Aditya Sharma's photo

Aditya Sharma

tutorial

MySQL Tutorial: A Comprehensive Guide for Beginners

Discover what MySQL is and how to get started in one of the most popular database management systems.
Javier Canales Luna's photo

Javier Canales Luna

tutorial

How to Install MongoDB on Ubuntu: A Step-by-Step Guide for Beginners

Learn how to install MongoDB on Ubuntu, configure the service, and verify the setup in this beginner-friendly tutorial.
Nic Raboy's photo

Nic Raboy

Se merSe mer