MySQL Tutorial

MySQL Installation and Configuration

MySQL Database Operations

Database Design

MySQL Data Types

MySQL Storage Engines

MySQL Basic Operations of Tables

MySQL Constraints

MySQL Operators

MySQL Function

MySQL Manipulate Table Data

MySQL View

MySQL Indexes

MySQL Stored Procedure

MySQL Trigger

MySQL Transactions

MySQL Character Set

MySQL User Management

MySQL Database Backup and Recovery

MySQL Log

MySQL Performance Optimization

Install And Config MySQL in Windows

MySQL is allowed to run on a variety of platforms, but installation methods vary from platform to platform. This section mainly introduces how to install and configure MySQL on the Windows platform.

There are two ways to install MySQL on the Windows platform:
  • MySQL graphical installation (.msi installation file).
  • Install-free version (.zip compressed file).

The steps for users to install and configure MySQL using the graphical installation package are as follows:

Install MySQL

Step 1): Double-click the downloaded MySQL installation file to enter the MySQL installation interface, first enter the "License Agreement" window, select the "I accept the license terms" check box, and click the "Next" button.

Some will directly enter the "Choosing a Setup Type" window, select the installation type that suits you according to the installation type description file on the right, and select the default installation type here, as shown in the figure.


  Note: There are 5 installation types listed in the figure, they are:
  1. Developer Default: The default installation type.
  2. Server only: only as a service.
  3. Client only: only as a client.
  4. Full: fully installed.
  5. Custom: Custom installation type.

Step 2): Install the Windows system framework according to the selected installation type, click the Execute button, and the installation program will automatically complete the installation of the framework, as shown in the figure.
 
Step 3): When the installer window pops up, tick the "I agree to the license terms and conditions" checkbox and click the "Install" button.
Step 4): The "Setup Successful" interface pops up, indicating that the framework has been installed, click the "Close" button. All frame installations can refer to this operation.
Step 5): After the installation is complete, Complete will be displayed under the [status] list. After the required frameworks are installed successfully, click the Next button, as shown in the figure.
 
Step 6): Enter the installation confirmation window, click the Execute button to start the installation of MySQL components, as shown in the figure.
 
Step 7): Start to install the MySQL file. After the installation is complete, Complete will be displayed under the [Status] list, as shown in the figure.
 

Configure MySQL

After the MySQL installation is completed, the server needs to be configured. The specific configuration steps are as follows:

Step 1): In the last step of the installation, click the Next button to enter the server configuration window, confirm the configuration information, and click the Next button after confirmation, as shown in the figure Show.


  Step 2): Enter the MySQL network type configuration window, use the default settings, and click the Next button, as shown in the figure.


  Step 3): Enter the MySQL server type configuration window, use the default settings, and click the Next button, as shown in the figure.


The specific meanings of the three options in the above figure are as follows:

  • Development Machine: The MySQL server installed as part of the development machine takes the least memory among the three optional types.
  • Server Machine: The installed MySQL server is part of the server machine, and the memory occupied is in the middle of the three types.
  • Dedicated MySQL Server Machine: Install a dedicated MySQL database server, occupying all the effective memory of the machine.


The MySQL port number defaults to 3306, if there is no special requirement, it is generally not recommended to modify it. Continue to click the Next button.
 


Step 4): Enter the password setting window of the server, enter the login password twice (letters and symbols are recommended), and click the Next button, as shown in the figure.

Step 5): Enter the server name window to set the server name, there is no special need and it is not recommended to modify it. Go ahead and click the Next button as shown.


  Step 6): Open the confirmation server setting window, click the Execute button to complete the configuration of MySQL, as shown in the figure.

After all the tests are passed, continue to click Finish and Next to install and the configuration is complete.

Step 7): Finally, open the Windows Task Manager dialog box, you can see that the MySQL service process mysqld.exe has been started, as shown in the figure.


So far, the installation and configuration of MySQL database under Windows operating system is completed.
  1. Configure MySQL on Windows 10/11:

    • Description: Configure MySQL settings on Windows, such as setting up the root password and configuring other options.
    • Command (to set root password):
      mysqladmin -u root password "new_password"
      
  2. Securing MySQL installation on Windows:

    • Description: Secure the MySQL installation on Windows by setting a strong root password and removing anonymous user accounts.
    • Commands:
      ALTER USER 'root'@'localhost' IDENTIFIED BY 'new_password';
      DELETE FROM mysql.user WHERE user = '' AND host = 'localhost';
      FLUSH PRIVILEGES;
      
  3. MySQL configuration file location in Windows:

    • Description: Find the MySQL configuration file on Windows, which typically is my.ini.
    • Default location:
      C:\ProgramData\MySQL\MySQL Server 8.0\my.ini
      
  4. Basic MySQL setup on Windows:

    • Description: Perform basic setup tasks on MySQL in Windows, including creating a new database and user.
    • Commands (in MySQL Command Line Client):
      CREATE DATABASE your_database;
      CREATE USER 'your_user'@'localhost' IDENTIFIED BY 'user_password';
      GRANT ALL PRIVILEGES ON your_database.* TO 'your_user'@'localhost';
      FLUSH PRIVILEGES;