首先我们需要先安装vc++2013否则可能出现,找不到msvcr110.dll文件
http://www.microsoft.com/zh-cn/download/details.aspx?id=40784
1.下载(操作系统为Windows Server 2016数据中心版)
https://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-5.7.19-winx64.zip
2.安装配置
解压完成之后放在C:\Program Files\mysql-5.7.19
添加环境变量
PATH=C:\Program Files\mysql-5.7.19\bin
配置MySQL配置文件C:\Program Files\mysql-5.7.19\my.ini
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
|
[mysqld]
basedir=C:\Program Files\mysql-5.7.19
datadir=C:\Program Files\mysql-5.7.19\data
#bind-address = 127.0.0.1
log-error=C:\Program Files\mysql-5.7.19\data\mysqld.log
pid-
file
=C:\Program Files\mysql-5.7.19\data\mysqld.pid
symbolic-links=0
skip-host-cache
skip-name-resolve
character-
set
-server=utf8
back_log=50
max_connections = 3000
binlog_cache_size = 4M
table_open_cache = 2500
max_connect_errors = 30
max_allowed_packet = 32M
max_heap_table_size = 128M
sort_buffer_size = 16M
thread_cache_size = 16
tmp_table_size = 128M
slow-query-log=1
long_query_time = 6
log_queries_not_using_indexes = 1
slow-query-log-
file
=C:\Program Files\mysql-5.7.19\data\slow.log
innodb_buffer_pool_size = 1G
innodb_flush_log_at_trx_commit = 1
innodb_log_files_in_group = 2
lower_case_table_names=1
server-
id
=1
log-bin=mysql-bin
sync_binlog = 1
expire_logs_days = 15
#replicate-ignore-db = mysql
#replicate-do-db = shop
binlog_stmt_cache_size = 1048576
#auto_increment_increment=2
#auto_increment_offset=1
#read_only = 1
[mysql]
default-character-
set
= utf8
|
初始化数据库
保证C:\Program Files\mysql-5.7.19\data目录有且为空
1
|
C:\Program Files\mysql-5.7.19\bin\mysqld --initialize
|
如果提示缺少msvcp120.dll或者msvcr120.dll,请安装vc++ 2013版本
https://www.microsoft.com/zh-cn/download/details.aspx?id=40784
注册服务
1
|
C:\Program Files\mysql-5.7.19\bin\mysqld
install
|
修改密码
1
2
|
mysqld --defaults-
file
=
"C:\Program Files\mysql-5.7.19\my.ini"
--console --skip-grant-tables
UPDATE user SET authentication_string=password(
"123456"
), host=
"::1"
WHERE User=
"root"
;
|
这个密码还不能用,关闭上面启动mysql数据库的窗口,然后启动服务
net start mysql
mysql -uroot -p123456
set password=password("db_password");
安装完成在使用的时候你会发现5.7之后的版本,date类型和datetime类型等无法设置为DEFAULT '0000-00-00'了
这个时候只需要修改mysql_mode即可
先查询
select @@session.sql_mode;
后面再修改,将NO_ZERO_IN_DATE, NO_ZERO_DATE删除,则为
1
|
sql_mode = ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION
|
添加到数据库配置文件中,并重新启动。
本文转自 rong341233 51CTO博客,原文链接:http://blog.51cto.com/fengwan/1962785