Table of contents
Installation environment: Win10 64-bit
software version: MySQL 5.7.24 decompressed version
1 download
Click the link to enter the following interface
❗️Note:
- We generally do not choose the latest version, but a more stable version.
Select the version corresponding to the number of bits in your systemDownload
and click on the right to download it.
2 installation
After the download is completed, what we get is a compressed package. After decompressing it, we can get the software body of MySQL 5.7.24 (which is a folder). We can put it in the location you want to install.
3 configuration
3.1 Add environment variables
There are many options in environment variables, here we only use
Path
this parameter. Why do we need to add environment variables at the beginning of initialization? Enter the name of an executable program in the black box (i.e. CMD). Windows will firstPath
search for it in the path pointed to in the environment variable. If it is found, it will be executed directly. If it is not found, it will be searched in the current working directory. If it is not found, it will be searched in the current working directory. If not found, an error will be reported. The purpose of adding environment variables is to be able to directly call related programs in MySQL in any black box without always modifying the working directory, which greatly simplifies the operation.
1️⃣ Right click 此电脑
→ 属性
, click高级系统设置
2️⃣ Click环境变量
3️⃣ 系统变量
New inMYSQL_HOME
4️⃣ 系统变量
Find and double-click onPath
5️⃣ Click新建
Finally click OK.
How to verify whether the addition is successful?
Right-click the Start menu (the lower left corner of the screen), select 命令提示符(管理员)
, open the black box, type mysql
, and press Enter.
- If prompted
Can't connect to MySQL server on 'localhost'
, the addition is successful; - If prompted
mysql不是内部或外部命令,也不是可运行的程序或批处理文件
, it means the addition failed, please recheck the steps and try again.
3.2 Create a new configuration file
Create a new text file with the following content:
[mysql]
default-character-set=utf8
[mysqld]
character-set-server=utf8
default-storage-engine=INNODB
sql_mode=STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION
The above code means that the default encoding set of the configuration database is utf-8 and the default storage engine is INNODB.
Save the above text file as, select the save type 所有文件 (*.*)
, file name my.ini
, and the storage path is MySQL 根目录
(for example, mine is D:\software\mysql-5.7.24-winx64
modified according to your own MySQL directory location).
3.3 Initialize MySQL
Type in the black box just now mysqld --initialize-insecure
, press Enter, and wait for a while. If no error message appears (as shown below), it proves that there is no problem with the data directory initialization. At this time, check that the data directory has been generated in the MySQL directory.
mysqld --initialize-insecure
Tips: If the following error occurs
It is caused by insufficient permissions. Go to C:\Windows\System32
the next page and run it as an administrator.cmd.exe
3.4 Register MySQL service
Type the following command in the black box and press Enter.
mysqld -install
The MySQL service is now installed on your computer. Your computer is also called a MySQL server, which is a machine with the MySQL service installed.
services.msc
Use the command to open the service list under Windows system
At this point, we can see that there are already MySQL
services in the service list
3.5 Start the MySQL service
Type the start mysql service command in the black box and press Enter.
net start mysql // 启动mysql服务
net stop mysql // 停止mysql服务
3.6 Modify default account password
Type in the black box mysqladmin -u root password 1234
. This 1234
refers to the password of the default administrator (i.e. root account). You can change it to what you like.
mysqladmin -u root password 1234
At this point, the MySQL 5.7 decompressed version is installed!
4 Login
Right-click on the Start menu, select 命令提示符
, and open the black box.
Enter in the black box, mysql -uroot -p1234
and press Enter. If the following picture appears and is in the lower left corner mysql>
, the login is successful.
mysql -uroot -p1234
From here you can start your MySQL journey!
Exit mysql:
exit
quit
Login parameters:
mysql -u用户名 -p密码 -h要连接的mysql服务器的ip地址(默认127.0.0.1) -P端口号(默认3306)
5 Uninstall
If you want to uninstall MySQL, it's easy.
Right-click on the Start menu, select 命令提示符(管理员)
, and open the black box.
1️⃣ Type net stop mysql
and press Enter.
net stop mysql
2️⃣ Type again mysqld -remove mysql
and press Enter
mysqld -remove mysql
Finally delete the MySQL directory and related environment variables.
At this point, MySQL uninstallation is complete!