1. Download
Official download address
https://dev.mysql.com/downloads/mysql/
2. Unzip
Directory structure after decompression:
3. Configure the my.ini file
- Create a my.ini file in the unzipped file directory
- Paste the following code into the my.ini file
[mysqld]
port=3306
basedir=C:\Program Files\mysql-8.0.23-winx64
datadir=C:\Program Files\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
- Modify path
- Change the path of basedir to
解压后文件的路径
- Change the path of datadir to
解压后文件的路径\Data
4. TakeAdministrator statusOpen cmd
- Use the dos command to enter the bin folder under the decompressed file
5. Initialize the database
Execute the following command in the bin folder
mysqld --initialize --console
Some computers encountered here: Cannot continue to execute code because vcruntime140_1.dll cannot be found
The problem that is not mysql is that the computer lacks a dynamic link library (.ddl file)
Download the vcruntime140_1.dll file at the link below and put it in the C:\Windows\System32
directory to solve it
https://cn.dll-files.com/vcruntime140_1.dll.html
Then re-execute
mysqld --initialize --console
Remember this temporary password
6. Installation Service
mysqld --install
7. Start the service (execute the following command in the bin folder)
net start MySql
8. Log in to the database (execute the following command in the bin folder)
mysql -u root -p
9. Change Password
Execute the following command in MySQL (modify the password verification plug-in, and modify the password at the same time.
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '新密码';
The installation has been completed so far! ! !
10. Configure environment variables
1. Why configure environment variables? ? ?
If you do not configure environment variables, you must enter the bin directory of MySQL every time you log in to the MySQL server, that is cd C:\Program FilesC:\Program Files\mysql-8.0.23-winx64\bin
, you can use other command tools such as MySQL after you enter a command, which is more troublesome. After configuring the environment variables, you can execute MySQL commands anywhere.
2. Configuration
Search environment variables
Find the path and edit it
Add a line to the bin directory under the decompressed file.
After adding it, you can always confirm
Then close cmd, reopen it as an administrator, execute the following statement in any directory to close the service, and the configuration is successful.
net stop mysql