MySQL5.7 Installation and Configuration Tutorial - Windows (commonly used version for enterprises) super detailed

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

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
insert image description here
insert image description here

  • Official website download address: https://dev.mysql.com/downloads/mysql/
    insert image description here
    Decompressed file directory structure: (After decompressing, you can change the name of the folder, for example, I changed it to: MySQL)
    insert image description here

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\MySQLand datadir=E:\develop\MySQL\Dataactually 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

insert image description here

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! ! !

  1. In CMD, switch directories to the bin directory in the MySQL decompression directory.
    insert image description here
  2. 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! ! !

insert image description here

4. Install the MySQL service

Excuting an order:mysqld --install MySQL

insert image description here

5. Start the MySQL service

Excuting an order:net start MySQL

insert image description here

6. Modify the initial password

  1. Excuting an order:mysql -u root -p
  2. Copy and paste the initial password generated when initializing MySQL, and press Enter to enter the MySQL service.
    insert image description here
  3. Execute the change password command
ALTER USER 'root'@'localhost' IDENTIFIED BY '新密码';

For example, I changed the password to ok

insert image description here

Exit the MySQL service command after the password is changed successfully:exit;

insert image description here

Then use the new password to log in and test it, execute the command: mysql -u root -p, and enter the new password:

insert image description here

success! Finish!

Guess you like

Origin blog.csdn.net/weixin_52799373/article/details/128467324