mysql日誌
阿新 • • 發佈:2020-07-24
1.mysql錯誤日誌
1.錯誤日誌預設是關閉的 2.預設路徑是 $datadir/,預設的名字是'主機名.err' 3.配置方式(一般場景所有配置) [root@db02 ~]# vim /etc/my.cnf [mysqld] server_id=1 basedir=/usr/local/mysql datadir=/usr/local/mysql/data port=3306 socket=/tmp/mysql.sock skip-name-resolve log_err=/usr/local/mysql/data/mysql.err [mysql] socket=/tmp/mysql.sock 4.檢視方式 [root@db02 ~]# mysql -e "show variables like '%log_err%'" +---------------------+---------------------------------+ | Variable_name | Value | +---------------------+---------------------------------+ | log_error | /usr/local/mysql/data/mysql.err | +---------------------+---------------------------------+
2.一般查詢日誌
1.檢視方式 mysql> show variables like '%general%'; +------------------+--------------------------------+ | Variable_name | Value | +------------------+--------------------------------+ | general_log | OFF | | general_log_file | /usr/local/mysql/data/db02.log | +------------------+--------------------------------+ 2 rows in set (0.00 sec) 2.預設是關閉的 3.預設路徑是 $datadir/,預設的名字是'主機名.log' 4.配置方式 [root@db02 ~]# vim /etc/my.cnf [mysqld] log_err=/usr/local/mysql/data/mysql.err general_log=on general_log_file=/usr/local/mysql/data/db02.log [mysql] socket=/tmp/mysql.sock
3.二進位制日誌
#注意: 1)binlog生成預設大小是120 2)binlog的大小也是binlog的當前位置點 1.檢視方式 mysql> show variables like '%log_bin%'; 2.二進位制日誌預設是關閉的 3.配置binlog [root@db02 ~]# vim /etc/my.cnf [mysqld] server_id #mysql5.7必須配置server_id log_bin=/usr/local/mysql/data/mysql-bin #mysql5.7只支援下劃線 #log-bin=/usr/local/mysql/data/mysql-bin #mysql5.6都支援 4.二進位制配置路徑和名字由配置檔案決定,一般儲存在$datadir/ 以'mysql-bin.000001'命令