天天看點

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,如需轉載請自行聯系原作者

繼續閱讀