introduction
MySQL 5.7 is the MySQL version commonly used by companies and enterprises.
Friends who are studying or working recommend relevant tutorials to learn and operate according to version 5.7.
1. Download MySQL
- Alibaba cloud disk unlimited speed download address: https://www.aliyundrive.com/s/YTMa5LfSFB2
Because Alibaba Cloud Disk does not support the sharing of zip archives, I used the 7z tool to create self-extracting archives. Double-click to run the exe to decompress
- Official website download address: https://dev.mysql.com/downloads/mysql/
Decompressed file directory structure: (After decompressing, you can change the name of the folder, for example, I changed it to: MySQL)
2. Initialize the my.ini file
Create the my.ini file in the MySQL unzipped directory. (If you don’t know how to create it, you can also download the finished product here: https://www.aliyundrive.com/s/YTMa5LfSFB2 )
Pay attention to modifying basedir=E:\develop\MySQL
and datadir=E:\develop\MySQL\Data
actually installing the path for yourself! ! !
[mysqld]
# 设置3306端口
port=3306
# 设置mysql的安装目录
basedir=E:\develop\MySQL
# 设置mysql数据库的数据的存放目录
datadir=E:\develop\MySQL\Data
# 允许最大连接数
max_connections=200
# 允许连接失败的次数。
max_connect_errors=10
# 服务端使用的字符集默认为utf8mb4
character-set-server=utf8mb4
# 创建新表时将使用的默认存储引擎
default-storage-engine=INNODB
# 默认使用“mysql_native_password”插件认证
#mysql_native_password
default_authentication_plugin=mysql_native_password
[mysql]
# 设置mysql客户端默认字符集
default-character-set=utf8mb4
[client]
# 设置mysql客户端连接服务端时默认使用的端口
port=3306
default-character-set=utf8mb4
3. Initialize MySQL
Run CMD as administrator! ! !
Run CMD as administrator! ! !
Run CMD as administrator! ! !
The commands executed in CMD in all subsequent steps are executed when running CMD as an administrator! ! !
The commands executed in all subsequent steps are executed in the bin directory of MySQL! ! !
- In CMD, switch directories to the bin directory in the MySQL decompression directory.
- Execute the initialization command:
mysqld --initialize --console
Note: root@localhost:
The last is the root initial password, this must be remembered, it will be used to log in and change the password later! ! !
4. Install the MySQL service
Excuting an order:mysqld --install MySQL
5. Start the MySQL service
Excuting an order:net start MySQL
6. Modify the initial password
- Excuting an order:
mysql -u root -p
- Copy and paste the initial password generated when initializing MySQL, and press Enter to enter the MySQL service.
- Execute the change password command
ALTER USER 'root'@'localhost' IDENTIFIED BY '新密码';
For example, I changed the password to ok
Exit the MySQL service command after the password is changed successfully:exit;
Then use the new password to log in and test it, execute the command: mysql -u root -p
, and enter the new password:
success! Finish!