Request-Response

The Full-Stack Blog

MySQL Installation Guide

February 06, 2024
Disponible en español

MySQL is a developer-friendly open source relational database management system. Reliable and easily scalable, MySQL powers the back end of many popular social, streaming, and service web applications.

To install MySQL on your machine, follow the instructions provided for your operating system.

Install MySQL Server on Windows

To install the MySQL server on a Windows computer, visit the MySQL Community Downloads page. In the Select Operating System dropdown menu, choose Microsoft Windows, as shown in the following image:

On the MySQL Community Downloads page, a red box outlines "Windows (x86, 32 & 64-bit), MySQL Installer MSI" and a blue "Go to Download Page" button.

Next to "Windows (x86, 32 & 64-bit), MySQL Installer MSI", select "Go to Download Page". On the next page, find the "Windows (x86, 32-bit), MSI Installer" option that is the smaller file size, and click the Download button. This should look like the following image:

On the MySQL installer downloads page, a red box outlines "Windows (x86, 32-bit), MSI Installer" and a blue Download button.

When prompted about signing up for a free Oracle Web account on the next page, select "No thanks, just start my download," as shown in the following image:

A yellow arrow points to blue text that says "No thanks, just start my download" at the bottom of the page.

Navigate to the folder where the file was downloaded, and double-click it to run the installer. If you get prompted for an update, select Yes. When you reach the page labeled "Choosing a Setup Type", check that "Server only" is selected, and click Next:

Under Choosing a Setup Type, "Server only" is selected, and the Next button appears at the bottom right of the screen.

On the next screen, entitled Download, you'll see your product listed (it should say "MySQL Server" followed by a version number). Click Execute to start the installation process, as shown in the following image:

On the Download screen, "MySQL Server 8.0.23" is listed under Product, and the status is "Ready to download". The Execute button appears at the bottom right of the screen.

After you click Execute, the status will be listed as Downloaded. Click Next, as shown in the following image:

Under Download, "MySQL Server 8.0.23" is highlighted and the status is listed as Downloaded. The Execute button appears at the bottom right of the screen.

The MySQL server is now ready for installation. Click Execute to begin the installation, as shown in the following image:

Under Install, the MySQL Server product type is listed, and the status is "Ready to Install". The Execute button appears at the bottom right of  screen.

Once the installation status shows as Complete, click Next, as shown in the following image:

Under Installation, the status is listed as Complete. The Next button appears at the bottom right of the screen.

Then click Finish on the next page, which should indicate Installation Complete, as shown in the following image:

Under Installation Complete, a message indicates,  "The installation procedure has been completed." The Finish button appears at the bottom right of the screen.

At this point, the installer should close on its own. Reopen it and click on the Reconfigure link under Quick Action, as shown in the following image:

In MySQL Installer, a Reconfigure link appears under Quick Action.

On the Type and Networking screen, don't change anything, and click Next.

Important On the Authentication Method screen, select "Use Legacy Authentication Method (Retain MySQL 5.x Compatibility)" and click Next, as shown in the following image:

Under Authentication Method, "Use Legacy Authentication Method (Retain MySQL 5.x Compatibility)" is selected. The Next button appears at the bottom right of the screen.

On the next screen, Accounts and Roles, you'll need to enter a strong password under Root Account Password, near the top of the screen. Make sure to enter a unique password that you've never used before. Then repeat your root password in the next field, as shown in the following image:

The Accounts and Roles screen features a field to enter and re-enter a password.

Caution Don't forget your password! It's extremely important that you keep track of your root password for MySQL, as it's difficult to reset. Write it down somewhere easily accessible, or add it to a password manager to keep it secure.

After entering your password twice and ensuring that you've stored it somewhere you can find it, click Next.

On the next screen, Windows Service, don't change anything, and click Next. On the Apply Configuration screen, click Execute to apply the changes, as shown in the following image:

Under Apply Configuration, no options are selected. The Execute button appears at the bottom right of the page.

After the configuration is complete, click Finish.

Note If you have any issues with the Windows (x86, 32-bit), MSI Installer that is the SMALLER file size, go back and download the LARGER size, following the same steps.

Now you'll need to add the PATH to the MySQL install to your environmental variables.

Add the MySQL PATH to Environmental Variables

First you'll need to copy the PATH to MySQL to your clipboard. Open any folder on your computer and select This PC in the left-hand navigation bar, as shown in the following image:

"This PC" is selected in the navigation bar.

Next, double-click your C: drive, as shown in the following image:

Under "Devices and drives", the C: drive is highlighted.

Double-click the Program files folder, then double-click the MySQL folder.

Note Depending on the version of Windows on your computer, MySQL might be inside the Program files (x86) folder.

Double-click the MySQL Server 8.0 folder, and finally, double-click the bin folder. Your screen should look like the following image:

The file path to the bin folder is highlighted at the top of the screen.

Right-click the address at the top of the screen and select "Copy address as text", like in the following image:

The file path at the top of the screen has been right-clicked, with "Copy address as text" selected on the menu.

Now that you've got the PATH copied to your clipboard, press the Windows key on your keyboard and search for "Edit the system environment variables". Once that appears in the search screen, click on it, as shown in the following image:

"Edit the system environment variables" is highlighted at the top of the search results.

You'll then be prompted with the System Properties screen. Navigate into the Advanced tab and select "Environment Variables...", as shown in the following image:

In the Advanced tab on the System Properties screen, "Environment Variables..." is highlighted at the bottom.

On the Environment Variables screen, under "User variables for <user>" (where <user> is your username on that computer), click into Path and then click the "Edit..." button in the top section of the screen. It should look like the following image:

On the Environment Variables screen, Path is selected and highlighted, with the "Edit…" button also highlighted.

In the "Edit environment variable" window, select New, as shown in the following image:

On the "Edit environment variable" window, the "New..." button is selected.

Your cursor will appear in a new line at the bottom of the variables. Paste your PATH in this box and click OK. Your screen should resemble the following image:

On the "Edit environment variable" screen, an empty box is highlighted, and OK is highlighted at the bottom of the screen.

Once you've added the PATH, restart Git Bash completely. You can verify that the installation was correct by typing the following into Git Bash:

mysql -V

The PATH followed by the MySQL version number should be printed to the screen. Once you verify that the MySQL server was correctly installed, you can move on to setting up MySQL Shell.

MySQL Shell on Windows

Important To use MySQL commands, you'll need to use MySQL Shell. You won't be able to access this shell through your Git Bash terminalyou'll need to use the Windows command prompt.

To open MySQL Shell, press the Windows key and the R key at the same time. This will bring up a dialog window titled Run. Enter "cmd" in the input and click OK, as shown in the following image:

In the Run dialog window, "cmd" has been entered in a text box, next to the word "Open".

This will open your Windows command prompt, which will look something like the following image:

The Windows command line displays a version number and copyright information.

From here, you'll be able to use the cd command to navigate to the directory where you're working. The following command, for example, will move you into the directory of a sample folder:

cd Desktop/sample-folder

You'll see something like the following image:

The command "cd Desktop/sample-folder" has been entered in the command line, and the sample folder has been accessed.

Once you're there, you'll need to log into MySQL Shell. To do so, enter the following command in the Windows command prompt:

mysql -u root -p

This tells MySQL Shell that you want to log in with the root user (-u). The -p syntax stands for "password." Once you enter this command, you'll be prompted for the root password that you created when you installed MySQL, as shown in the following image:

In the command line, the login command has been entered, and the user is prompted to enter a password.

Enter your password and press the Enter key. This will log you into MySQL Shell, as shown in the following image:

In the command line, the user is greeted with a welcome message to MySQL Shell.

From here, you'll be able to enter MySQL commands. You don't need to do this now, but you can revisit these instructions as you work through this module.

Type the command quit; to exit MySQL Shell.

Deep Dive You can also access MySQL Shell directly in VS Code! Depending on how you set up Git Bash, this option might already be available to you. Select Terminal from your menu at the top of the screen, and select New Terminal in the dropdown menu, as shown in the following image:

At the top of the Terminal dropdown menu in VS Code, New Terminal is highlighted.

If a terminal appears at the bottom of your screen with "cmd", "powershell", or "bash" selected, you're ready to go. You can click on this dropdown to choose the integrated terminal of your choice. See the following image for an example:

"bash" is highlighted in a dropdown menu in the CLI at the bottom of the VS Code screen.

If you can't access an integrated terminal and you want to, see the VS Code documentation on the integrated terminal.

Install MySQL Server on macOS

Please choose only one of the following options, but not both:

Method 1: Install MySQL from the Homebrew package manager

One method to install MySQL Server on macOS is to through the Homebrew package manager. This will allow you to install MySQL Server from the command line.

Once you have Homebrew installed, you can install MySQL Server using the following command:

brew install mysql

The server is set up without a default root password. You can connect to it using the following command:

mysql -uroot

Important: (Optional) You should change the root password after you install MySQL Server. You can do this with the following command:

mysql_secure_installation

Method 2: Install MySQL from the MySQL website

Another method to install the MySQL server on macOS is to download it from the MySQL Community Downloads page. Select macOS from the dropdown menu and then scroll down to find the DMG Archive version of the MySQL server installer, which should be the first one on the list. It will be labeled "macOS 10.xx (x86, ARM, 64-bit), DMG Archive", where "xx" is a combination of numbers, as show in the following image:

Note: The MySQL Community Server version number might be different from what appears in these following images.

On the MySQL macOS downloads page, a red box outlines "macOS 10.15 (x86, 64-bit), DMG Archive" and a blue Download button.

Click Download.

On the next page, select "No thanks, just start my download", as shown in the following image:

A yellow arrow points to blue text that says, "No thanks, just start my download" at the bottom of the screen.

Open the DMG file after it has downloaded and go through the installation process.

Note If you see a message that the installer cannot check the file for malicious software, try right-clicking to select Open.

Click Continue to get to the Software License Agreement screen. Click Continue again on that screen, then select Agree, as shown in the following image:

A dialog box displays options to Read License, Disagree, or Agree, with a yellow arrow pointing to Agree.

Click Install and input your password to allow the installer to continue.

Important On the Configure MySQL screen, make sure to select "Use Legacy Password Encryption" and click Next, as shown in the following image:

On the installation window, "Use Legacy Password Encryption" is selected.

Now create a root password.

Caution Don't forget this password! It's extremely important that you keep track of your root password for MySQL, as it's difficult to reset. Write it down somewhere easily accessible or add it to a password manager.

Enter a root password on the next screen. After entering your password and ensuring that you've stored it somewhere you can find it, click Finish, as shown in the following image:

A hidden password has been entered in the installation window, with a yellow arrow pointing to a Finish button.

You can verify that the installation was correct by going to System Preferences and checking that the MySQL icon shows up at the bottom. You'll see something like the following image:

At the bottom of the System Preferences window, a yellow arrow points to the MySQL icon.

Note You can start or stop your MySQL server by clicking on the MySQL icon in System Preferences. This will bring up a GUI that you can set to automatically start the MySQL server when you turn on your computer, like in the following image:

In a MySQL GUI, a yellow arrow points to the option to "Start MySQL when your computer starts up", which is selected.

You might need to restart your computer to change these settings in System Preferences.

Once you've verified that the MySQL server was installed correctly, move on to setting up MySQL Shell.

MySQL Shell on macOS

You can use MySQL Shell simply by opening a new terminal and logging into MySQL Shell. Before you can do this, you might need to start the MySQL server, with the following steps:

  1. Go to System Preferences and click the MySQL icon.

  2. Click "Start MySQL Server".

Open Terminal and use the cd command to navigate to a directory where you'll be workingfor example, one of your project folders. Once in the directory, enter the following command to initialize the MySQL command-line prompt:

mysql -u root -p

This tells MySQL Shell that you want to log in with the root user (-u). The -p syntax stands for "password." Once you enter this command, you should be prompted for the root password that you created when you installed MySQL. Enter your password and press the Enter key. This will log you into MySQL Shell, as shown in the following image:

In Terminal, the user is greeted with a welcome message to MySQL Shell.

From here, you'll be able to enter MySQL commands. You don't need to do this now, but you can revisit these instructions as you work through this module.

Type the command quit; to exit MySQL Shell.

Note Some macOS users might get the error message "Command not found". If that is the case, we will need to set up a .zshrc file in your home directory and add the mysql command to it. To do this, run the following command:

echo 'export PATH="/usr/local/mysql/bin:$PATH"' >> ~/.zshrc

When you’re done, restart your terminal for this line to take effect. You can then try initializing MySQL Shell again with the following command:

mysql -u root -p

This page was updated 6 months ago
© 2022 edX Boot Camps LLC. Confidential and Proprietary. All Rights Reserved.

Category: mysql

Tagged under: mysql, mysql server, windows installation, mac installation, installation, guide, sql, databases,

All Posts