If you want to use MySQL in your projects, the first step is installing and setting it up on your machine. This tutorial guides you on how to install MySQL on Windows, macOS, and Linux operating systems.



Before we start, it is essential to know that MySQL comes in two versions. The first version is the MySQL Community Edition, which is free and open-source, and the other version is the MySQL Enterprise Edition, a paid version with extra features and support. However, this tutorial will only focus on the Community Edition.

Before you begin, make sure you have the following requirements:

  • A computer with a supported OS: Windows, macOS, or Linux
  • Administrative user account
  • Internet connection

Once you have these prerequisites, you can begin the installation process.

Windows OS

To install MySQL on Windows, follow these steps:

  1. Download the MySQL installer from the official MySQL website (https://dev.mysql.com/downloads/mysql/).
  2. Double-click the installer to launch it.
  3. Click "Next" to begin the installation process.
  4. Accept the terms of the license agreement and click "Next."
  5. Choose the installation type (e.g., Developer Default, Server Only, or Custom). We recommend choosing the Developer Default option if you're just getting started with MySQL.
  6. Click "Next" to continue.
  7. Choose the installation location and click "Next."
  8. Set the root password for your MySQL installation and click "Next." Make sure to choose a strong password that you will remember.
  9. Click "Execute" to begin the installation process.
  10. Wait for the installation to finish, then click "Finish" to complete the setup.

macOS

To install MySQL on macOS, follow these steps:

  1. Download the MySQL installer from the official MySQL website (https://dev.mysql.com/downloads/mysql/).
  2. Double-click the installer to launch it.
  3. Click "Continue" to begin the installation process.
  4. Click "Agree" to accept the terms of the license agreement.
  5. Choose the installation location and click "Install."
  6. Enter your user password and click "Install Software."
  7. Wait for the installation to complete, then click "Close."

Linux OS

To install MySQL on a Linux machine, you have several options. The most common method is to use the package manager for your Linux distribution. For example, on a Debian-based system, you can use the apt-get command to install MySQL:

To install MySQL on Linux, follow these steps:

  1. Run the following command to add the MySQL APT repository to your system:
    wget https://dev.mysql.com/get/mysql-apt-config_0.8.14-1_all.deb
    sudo dpkg -i mysql-apt-config_0.8.14-1_all.deb
    
  2. Run the following command to update your package list:
    sudo apt-get update
  3. Run the following command to install MySQL:
    sudo apt-get install mysql-server
  4. You'll be prompted to set the root password for your MySQL installation during installation. Make sure to choose a strong password that you will remember.

    Verifying the Installation

    To verify that MySQL has been installed and is running correctly, follow these steps:

    1. Open a terminal window.
    2. Run the following command:
      mysql -u root -p
  5. Enter the root password you set during the installation process. If the installation was successful, you should see the MySQL command prompt.
  6. Exit MySQL by running the following command on the MySQL prompt:
    exit;
  7. You can create and manage databases once MySQL is installed and set up.

Installing MySQL is a straightforward process that can be completed in just a few steps. The process is essentially the same whether you're using Windows, macOS, or Linux. Once MySQL is installed, you must set up a root user and password to get started. With these steps under your belt, you're ready to dive into the world of MySQL and start creating and managing your databases.



Found This Page Useful? Share It!
Get the Latest Tutorials and Updates
Join us on Telegram