The difficulty of things is far less than the fear of things
1. Download
MySQL 8.0.23 download address
Open the webpage and the following interface will appear. Here, first select the Windows system version, and then click the Download option below.
Then the following interface will appear, you don’t need to log in, just click the button below to download.
2. Unzip
Unzip the downloaded MySQL compressed package to your favorite path. I unzip it under the path shown in the figure below.
3. Add environment variables
Right-click My Computer on the computer desktop—>Properties—>Advanced System Settings—>Environment Variables—>Double-click PATH—>New—>Paste your own MySQL decompression directory in the edit box—>Click OK in turn, the process is shown in the figure below .
4. Create my.ini configuration file
Create a text document in the MySQL decompression directory, then rename it to my.ini, then open it with Notepad, copy and paste the following code into it, and finally save it.
[mysqld]
port=3306
basedir=D:\\software\\mysql-8.0.23-winx64
datadir=D:\\software\\mysql-8.0.23-winx64\\data
max_connections=200
max_connect_errors=10
character-set-server=utf8mb4
default-storage-engine=INNODB
#mysql_native_password
default_authentication_plugin=mysql_native_password
[mysql]
default-character-set=utf8mb4
[client]
port=3306
default-character-set=utf8mb4
Note: To replace the paths in the third and fourth lines of the code above. Change it to the path you decompress yourself, and the hierarchical directories must be \\
represented, otherwise subsequent operations will go wrong. There are no folders in the original decompression directory data
. You can create an empty data
folder by yourself, or you can leave it alone. It will be created automatically when you initialize the database later.
5. Configure the MySQL database
Start by running a Command Prompt window as an administrator.
Then enter the directory MySQL
inside the unzipped directory bin
.
C:\Users\Suur>D:
D:\>cd software
D:\software>cd mysql-8.0.23-winx64
D:\software\mysql-8.0.23-winx64>cd bin
D:\software\mysql-8.0.23-winx64\bin>
Then start configuring the MySQL database.
- install mysql
Enter the following command
mysqld -install
If the following code prompts success, proceed to the following operation.
D:\software\mysql-8.0.23-winx64\bin>mysqld -install
Service successfully installed.
- Initialize data files
Enter the following command:
mysqld --initialize-insecure --user=mysql
If no error is reported, wait for a while. After the processing is completed, a folder MySQL
will be automatically created in the decompression directory , and it will contain many files. data
If the following error is reported, it is because my.ini
the directory hierarchy relationship in the configuration file is not indicated \\
, and the configuration will be successful after modification.
- Bypass password verification
Enter the following command:
mysqld --console --skip-grant-tables --shared-memory
Then close the current cmd window now, open a new cmd window as an administrator, and switch to the bin directory under the MySQL directory.
- Start the MySQL service
Enter the following command:
net start mysql
The cmd window will prompt that the service has started successfully.
- Enter the management interface
Enter the following command:
mysql -u root -p
You will be prompted to enter the password. You don’t need to enter anything at this time, just press Enter. If the following command is displayed, it will show that the entry is successful.
D:\software\mysql-8.0.23-winx64\bin>mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 9
Server version: 8.0.23 MySQL Community Server - GPL
Copyright (c) 2000, 2021, Oracle and/or its affiliates.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql>
- change Password
Enter the following command:
ALTER USER 'root'@'localhost' IDENTIFIED BY '123789';
Among them, 123789 is the new password, and the following instructions are displayed. That means the modification is successful.
mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY '123789';
Query OK, 0 rows affected (0.01 sec)
- exit and close the service
At this point, the password has been successfully changed, and now execute the following command to exit.
mysql> quit
Bye
Then execute the following command to shut down the service.
D:\software\mysql-8.0.23-winx64\bin>net stop mysql
MySQL 服务正在停止.
MySQL 服务已成功停止。
6. Use the MySQL database
Now you have configured your own MySQL database, the user name is root, and the password is the password you just modified yourself, here is 123789. First execute the following command to start the service:
net start mysql
Then execute the following command and enter your own password to use the database.
D:\software\mysql-8.0.23-winx64\bin>mysql -u root -p
Enter password: ******
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 11
Server version: 8.0.23 MySQL Community Server - GPL
Copyright (c) 2000, 2021, Oracle and/or its affiliates.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql>
Finish! ! !
Next, you can move to learn the basic instructions of MySQL written by me:
Basic learning of MySQL database (1) Database operation instructions
Basic learning of MySQL database (2) Operation instructions of data table
Basic learning of MySQL database (3) Data operation instructions