一、MySQL安装

1、官网下载社区版

2、解压缩到C盘:C:\mysql-5.7.21-winx64

3、以管理员身份运行命令行,进入目录C:\mysql-5.7.21-winx64\bin

4、注册服务:C:\mysql-5.7.21-winx64\bin>mysqld install mysql5.7.21

5、初始化数据库:C:\mysql-5.7.21-winx64\bin>mysqld --initialize

6、启动数据库:C:\mysql-5.7.21-winx64\bin>net start mysql5.7.21

7、登录数据库:C:\mysql-5.7.21-winx64\bin>mysql -u root -p

注意,登录密码从mysql安装目录 *.err 文件中找,例如标红字符:2018-01-17T09:26:11.260249Z 1 [Note] A temporary password is generated for root@localhost: _=(H,?pX.7yZ

8、修改root用户密码:C:\mysql-5.7.21-winx64\bin>mysqladmin -u root -p _=(H,?pX.7yZ password 1234

二、MySQL配置

自行创建 C:\mysql-5.7.21-winx64\my.ini,文件内容如下:

[mysqld]
#设置3306端口
port = 3306
# 设置mysql的安装目录
basedir=C:\mysql-5.7.21-winx64
# 设置mysql数据库的数据的存放目录
datadir=C:\mysql-5.7.21-winx64\data 
# 允许最大连接数
max_connections=200
# 服务端使用的字符集默认为8比特编码的latin1字符集
character-set-server=utf8
# 创建新表时将使用的默认存储引擎
default-storage-engine=INNODB
# 设置成严格模式
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES

[mysql]
# 设置mysql客户端默认字符集
default-character-set=utf8
Like The Article To View All

All Comments

Leave a Reply Cancel Reply

Tips: Your email address will not be disclosed!

If you can't see clearly,please click to change...