Installation of MySQL

Installation of MySQL - Step-by-Step Guide

Installing MySQL is a straightforward process, but it can vary slightly depending on your operating system. Below is a detailed, easy-to-follow guide for installing MySQL on Windows, macOS, and Linux.


Installing MySQL on Windows

Step 1: Download MySQL Installer

  1. Go to the official MySQL website: https://dev.mysql.com/downloads/installer/.

  2. You will see two download options: "MySQL Installer - Web" and "MySQL Installer - Full." Choose the "Full" version if you want all features included or the "Web" version for a smaller download (which will fetch components during installation).

  3. Click the "Download" button. You may be asked to log in or sign up for an Oracle account, but you can skip this step by clicking "No thanks, just start my download."

Step 2: Run the MySQL Installer

  1. Once the download is complete, locate the installer file (usually in your Downloads folder) and double-click it to run.

  2. You may be prompted by Windows User Account Control (UAC) to allow the installer to make changes to your system. Click "Yes" to proceed.

Step 3: Choose Setup Type

  1. The MySQL Installer will open, and you will be asked to select a setup type:

    • Developer Default: Installs all necessary components for developers, including MySQL Server, MySQL Workbench, and connectors.

    • Server Only: Installs only the MySQL Server.

    • Client Only: Installs MySQL client tools without the server.

    • Full: Installs all MySQL products and features.

    • Custom: Allows you to choose specific components.

  2. For beginners, the Developer Default option is recommended. Select it and click "Next."

Step 4: Check Requirements

  1. The installer will check if your system meets the necessary requirements. If anything is missing (e.g., Microsoft Visual C++), the installer will prompt you to download and install it.

  2. After installing any required components, click "Next" to proceed.

Step 5: Installation

  1. The installer will list the products that will be installed. Review the list and click "Execute" to start the installation.

  2. The installation process may take a few minutes. Once complete, click "Next."

Step 6: MySQL Configuration

  1. High Availability: Choose "Standalone MySQL Server" and click "Next."

  2. Type and Networking: Choose the default "Development Computer" option. Ensure the port number is set to 3306 and click "Next."

  3. Authentication Method: Choose "Use Strong Password Encryption for Authentication (RECOMMENDED)" and click "Next."

  4. Accounts and Roles: Set a root password. This is the main password for your MySQL server, so make sure to remember it. You can also create additional user accounts if needed.

  5. Windows Service: Ensure that "Configure MySQL Server as a Windows Service" is checked, and set the service to start automatically. Click "Next."

Step 7: Apply Configuration

  1. Click "Execute" to apply the configuration settings. Once complete, click "Finish."

Step 8: Complete Installation

  1. The final screen will show that MySQL has been successfully installed. You can choose to launch MySQL Workbench and MySQL Shell if you want to start using MySQL immediately. Click "Finish" to exit the installer.


Installing MySQL on macOS

Step 1: Download MySQL DMG

  1. Go to the official MySQL website: https://dev.mysql.com/downloads/mysql/.

  2. Choose macOS from the dropdown menu and download the DMG archive.

  3. Click "Download." You may skip the login/signup by clicking "No thanks, just start my download."

Step 2: Install MySQL

  1. Once the download is complete, open the DMG file.

  2. Double-click the MySQL installer package (it will have a .pkg extension).

  3. Follow the installation prompts:

    • Click "Continue" on the introductory screen.

    • Read and accept the license agreement.

    • Choose the installation location (the default is usually fine).

    • Click "Install" to start the installation process.

Step 3: Configure MySQL

  1. After installation, you will be prompted to configure MySQL.

    • Root Password: Set a strong root password and click "Finish."

    • Start MySQL at Boot: Choose whether you want MySQL to start automatically when your Mac boots.

Step 4: Start MySQL

  1. To start MySQL, go to "System Preferences" and find the MySQL icon at the bottom of the screen.

  2. Click the MySQL icon and click "Start MySQL Server."

Step 5: Verify Installation

  1. Open Terminal (found in Applications > Utilities).

  2. Type the following command to check if MySQL is running:

    mysql -u root -p
  3. Enter the root password you set during installation. If you see the MySQL prompt, the installation was successful.


Installing MySQL on Linux (Ubuntu)

Step 1: Update Your Package List

  1. Open Terminal.

  2. Update your package list to ensure you get the latest version of MySQL:

    sudo apt update

Step 2: Install MySQL

  1. Install MySQL using the following command:

    sudo apt install mysql-server
  2. The installation process will begin. You may be prompted to confirm the installation by typing "Y" and pressing Enter.

Step 3: Secure MySQL Installation

  1. After installation, it is recommended to run a security script that comes with MySQL. This will help you set a root password, remove test databases, and disable remote root login.

    sudo mysql_secure_installation
  2. Follow the prompts to configure security settings. You will be asked to set a root password, which you should remember.

Step 4: Start MySQL

  1. Start the MySQL service (if it isn't already running) with the following command:

    sudo systemctl start mysql
  2. Enable MySQL to start automatically at boot:

    sudo systemctl enable mysql

Step 5: Verify Installation

  1. Log in to the MySQL server as the root user:

    sudo mysql -u root -p
  2. Enter the root password you set during the security script. If you see the MySQL prompt, the installation was successful.


Conclusion

Once you have successfully installed MySQL, you can start creating and managing databases. MySQL Workbench, which is included in most installations, provides a graphical interface to interact with your databases, making it easier to perform various SQL operations. This step-by-step guide is designed to help students get MySQL up and running on their system, regardless of the operating system they are using.

This tutorial is brought to you by codes with pankaj.

Last updated