Detailed Mysql installation tutorial

mysql official website download address: https://dev.mysql.com/downloads/mysql/ .

Here is the 5.7.20 version as an example

1. After the installation package is decompressed , there is no data folder and my-default.ini mentioned in the online tutorial, as shown in the figure below

Insert picture description here

2. Configure environment variables:
that is, add the path of MYSQL decompression package bin in Path in the environment variable, mine is:
D:\softnew\MYSQL\mysql-5.7.20-winx64\bin
Mainly pay attention to the following points:
(1) It is not important whether the my-default.ini file exists or not . The key is to create a new my.ini file in the root directory. The specific content is as follows:

[mysql]
# 设置mysql客户端默认字符集
default-character-set=utf8 
[mysqld]
#设置3306端口
port = 3306 
# 设置mysql的安装目录
basedir=D:\\softnew\\MYSQL\\mysql-5.7.20-winx64
# 允许最大连接数
max_connections=200
# 服务端使用的字符集默认为8比特编码的latin1字符集
character-set-server=utf8
# 创建新表时将使用的默认存储引擎
default-storage-engine=INNODB

You can copy and paste directly, mainly modify the path after basedir. Note that the path is \ instead of
(2) Please do not create the data folder
yourself. Many online tutorials suggest that you create an empty data folder yourself, and then add it to the my.ini file One sentence:

# 设置mysql数据库的数据的存放目录
datadir=D:\\softnew\\MYSQL\\mysql-5.7.20-winx64\\data

But this will cause the service to fail to start, do not add this sentence, and do not create a new data folder yourself, just generate data automatically by mysql
(3) Specific operations :
1) Open the cmd command window as an administrator (open cmd directly to run , An error may be reported), and enter the bin directory of the mysql installation directory. Then enter the command mysqld install and show success
2) Then enter: mysqld --initialize There should be no prompt at this time
3) Then enter: net start mysql shows

Finally, the contents of the data folder should be displayed as:
Insert picture description here

note:
When logging in to MYSQL for the first time, you will be prompted to enter the initial password. This is for security reasons. The command: mysqld --initialize will randomly generate a password.
The initial password is in the xxx.err file under the data folder in the above figure. You can open it with Notepad and use the ctrl+f search function to find the following line of records:

[Note] A temporary password is generated for root@localhost: NZ+uhXPq1zN.

Among them, NZ+uhXPq1zN. is the initial password (note that the number should not be missed)

After entering, you can use the following command to modify, here the password is changed to root:

ALTER USER 'root'@'localhost' IDENTIFIED BY 'root';

Here is version 5.7.22, the display is basically as follows:
Insert picture description here

Guess you like

Origin blog.csdn.net/javaScript1997/article/details/108938064