天天看点

Windows下Mysql 5.7.19 开启bin-log以及mysql配置

一、配置环境:

OS:Win10

Mysql:5.7.19

二、我的Mysql配置文件(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

<code>[client]</code>

<code>port=3306</code>

<code>default-character-</code><code>set</code><code>=utf8</code>

<code>[mysqld] </code>

<code>#Path to install software directory </code>

<code>basedir=E:\mysql-5.7.19</code>

<code>#Path to the database directory</code>

<code>datadir=G:\mysql_data</code>

<code>#Port Number</code>

<code>#created  and no character set is defined</code>

<code>character_set_server=utf8</code>

<code>#Set the SQL mode to strict</code>

<code>sql_mode=</code><code>"NO_ENGINE_SUBSTITUTION,NO_AUTO_CREATE_USER,STRICT_TRANS_TABLES"</code>

<code>explicit_defaults_for_timestamp=</code><code>true</code>

<code># Binary Logging</code>

<code>log-bin=mysql-bin</code>

<code>binlog-</code><code>format</code><code>=Row</code>

<code>#The default storage engine that will be used when create new tables when</code>

<code>default-storage-engine=INNODB</code>

<code>#General and Slow logging</code>

<code>log-output=FILE</code>

<code>general-log=0</code>

<code>general_log_file=</code><code>"yuri.log"</code>

<code>slow-query-log=1</code>

<code>slow_query_log_file=</code><code>"yuri-slow.log"</code>

<code>long_query_time=10</code>

<code>#Error Logging</code>

<code>log-error=</code><code>"yuri.err"</code>

<code>#Server ID</code>

<code>server-</code><code>id</code><code>=201609</code>

备注:

   在MySQL 5.7.3 及以后版本,如果没有设置server-id, 那么设置binlog后无法开启MySQL服务. (Bug #11763963, Bug #56739)

另外一种配置方式:

<code>#log_bin=ON</code>

<code>#log_bin_basename=G:\mysql_data\mysql-bin</code>

<code>#log_bin_index=G:\mysql_data\mysql-bin.index</code>

不过默认也是上面这样的

三个参数含义:

1、参数是打开binlog日志

2、参数是binlog日志的基本文件名,后面会追加标识来表示每一个文件

3、参数指定的是binlog文件的索引文件,这个文件管理了所有的binlog文件的目录

三、启动mysql 测试并检查是否看起成功,如下图可以看到启动成功

show variables like '%log_bin%';

<a href="https://s2.51cto.com/wyfs02/M02/03/C6/wKiom1mf38KyBleuAABfrYgWKwg819.jpg-wh_500x0-wm_3-wmp_4-s_3322542542.jpg" target="_blank"></a>

本文转自 yuri_cto 51CTO博客,原文链接:http://blog.51cto.com/laobaiv1/1959360,如需转载请自行联系原作者

继续阅读