Install MySQL for Windows

directory

(a) installation

(2) Add the login password of user root


(a) installation

1. Download the installation-free MySQL (Community Edition) software package.

Download address: dev.mysql.com/downloads/m…

2. Decompress the software package

This tutorial is to unzip the package into the “D:\mysql” directory.

3. Access the CLI

Take Windows 7 as an example.

[Start] – [Search programs and files] Enter “CMD”, click the right mouse button on the search program icon, and choose “Run as administrator”.

4. Go to the MySQL directory

. >d:

. >cd D:\mysql\bin

5. Initialize MySQL

You can initialize the password with or without a password. You are advised to initialize the password without a password (you can set a password) to avoid random password loss.

D:\mysql\bin>mysqld --initialize

D:\mysql\bin>mysqld --initialize-insecure

6. Install mysqld

D:\mysql\bin>mysqld -install

Tip: “mysql” is used to execute SQL commands, “mysqld” is used to execute database commands.

7. Start the MySQL service

. >net start mysql

8. Log in to MySQL

. >mysql -u root -p

Enter password :(if there is no password, press Enter)

(2) Add the login password of user root

1. Stop the MySQL service

D:\mysql\bin>net stop mysql

D:\mysql\bin>mysqld --console --skip-grant-tables

In this case, no command can be entered in the current CLI window.

Open another command line window and go to D:\mysql\bin>.

3. Log in to MySQL

D:\mysql\bin>mysql -u root -p

Enter password :(press Enter without password)

4. Switch the database

mysql>use mysql;

5. Run the statement to change the password

Password rule: The password must contain uppercase letters, lowercase letters, special characters, and at least eight characters, for example, Opython.com666.

mysql>update mysql.user set authentication_string=password('Opython.com666') where user='root';

6. Refresh permissions and exit MySQL

mysql>flush privileges;

mysql>quit;

7. Terminate mysqld

Back to the first cli window, press Ctrl+C to end the process or press Ctrl+Alt+Del to open the task Manager and end the mysqld.exe process.

8. Restart the MySQL service

. >net start mysql

9. Log in to MySQL

D:\mysql\bin>mysql -u root -p

Enter password:Opython.com666

In this case, you must use the new password to log in to MySQL.