MySQL - Installation on Linux and Windows

Steps to install MySQL on Windows along with steps to validate the installation:

  1. Download MySQL Installer: Download the MySQL Installer from the official MySQL website (https://dev.mysql.com/downloads/installer/) and choose the appropriate version based on your system specifications.
  2. Run MySQL Installer: Once the installer file is downloaded, double-click on the file to run the installer.
  3. Choose Setup Type: On the setup screen, choose the setup type that you want to install. For beginners, it is recommended to choose the Developer Default setup type, which installs MySQL Server, MySQL Shell, MySQL Router, and other essential components.
  4. Download Required Files: After choosing the setup type, the installer will download and install the required files for the selected components.
  5. Configure MySQL Server: Once the download and installation of required files are complete, you will be prompted to configure MySQL Server. On the configuration screen, you can choose the type of installation, provide the root password, and set the port number for MySQL Server.
  6. Complete Installation: After configuring MySQL Server, click on the Install button to complete the installation process. Wait for the installation to finish.
  7. Validate Installation: To validate the MySQL installation, follow these steps:
    a. Open Command Prompt: Press the Windows key + R to open the Run dialog box. Type cmd and press Enter to open Command Prompt.
    b. Check MySQL Version: Type mysql -v and press Enter to check the installed MySQL version. If MySQL is installed correctly, it will display the version number.
    c. Check MySQL Service: Type sc query MySQL and press Enter to check if the MySQL service is running. If the service is running, it will display the status as "RUNNING".
    d. Check MySQL Connection: Type mysql -u root -p and press Enter to connect to MySQL Server using the root user. Enter the root password that you set during the installation process. If the connection is successful, it will display the MySQL command prompt.

Steps to install MySQL on Linux along with steps to validate the installation:

  1. Update the package list: sudo apt-get update
  2. Install the MySQL server and client packages: sudo apt-get install mysql-server mysql-client
  3. During the installation process, you will be prompted to set a password for the root user. Make sure to remember this password as it will be needed later.
  4. After the installation is complete, start the MySQL service: sudo service mysql start
  5. By default, MySQL is configured to only allow connections from the localhost. To allow remote connections, you need to edit the MySQL configuration file. Open the file using the following command: sudo nano /etc/mysql/mysql.conf.d/mysqld.cnf
  6. In the [mysqld] section of the file, look for the line that says bind-address and change its value to 0.0.0.0 to allow remote connections.
  7. Restart the MySQL service to apply the changes: sudo service mysql restart
  8. To verify that the installation was successful, you can run the following command to check the status of the MySQL service: sudo service mysql status
  9. You can also test the MySQL installation by logging in to the MySQL command-line client: mysql -u root -p
  10. You will be prompted for the root user password. Enter the password you set during the installation process.
  11. If you are able to log in successfully, you can run the following command to view a list of databases: show databases;
  12. Exit the MySQL command-line client by typing exit;