Install mysql5.7 using the command under windows

Unzip the zip archive and create the my.ini file with the following contents

Note here that sql_mode is written here to make mysql use habit similar to oracle, and what it means is easy to find on Baidu

[mysql]

# Set the default character set of the mysql client

default-character-set=utf8

[mysqld]

sql_mode='NO_AUTO_VALUE_ON_ZERO,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION,PIPES_AS_CONCAT,ANSI_QUOTES'

#Set 3306 port

port = 3306

# Set the installation directory of mysql

basedir=E:\mysql-5.7.13-winx64

# Set the storage directory for the data of the mysql database

datadir=E:\mysql-5.7.13-winx64\data

# maximum number of connections allowed

max_connections=200

# The character set used by the server defaults to the 8-bit encoded latin1 character set

character-set-server=utf8

# The default storage engine that will be used when creating new tables

default-storage-engine=INNODB

 

Initialize and start the Mysql service:

1. Run cmd with administrator privileges (note that win10 must be cmd with administrator privileges)

2. Enter the bin of mysql

 

3. Initialize, generate data folder

 >mysqld --initialize-insecure (do not set root password, recommended)

 >mysqld --initialize (generates a random root password - this root password will be displayed in the command prompt, be sure to write it down... or not tragedy)

After the command is executed, a data folder will be generated in the mysql file directory, and the time will be slower.

 

3. Install MySql service

 >mysqld -install

4.启动mysql

 >net start mysql

登陆mysql

>mysql -u root -p

第一次登录时无需密码直接回车登录

登录mysql之后,设置root密码

>set password for root@localhost =password('YourPassword');

或者使用mysqlamdin修改root密码

>mysqladmin -u root -p password NewPassword

 

修改密码后,我们使用root可登录成功

 

参考: https://blog.csdn.net/qq_28126403/article/details/53995216

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326021739&siteId=291194637