導航:首頁 > 程序命令 > mysql命令日誌

mysql命令日誌

發布時間:2022-08-07 08:51:15

㈠ 如何開啟mysql的日誌或如何查看 mysql的日誌文件

mysql有以下幾種日誌:
錯誤日誌: -log-err
查詢日誌: -log
慢查詢日誌: -log-slow-queries
更新日誌: -log-update
二進制日誌: -log-bin
在mysql的安裝目錄下,打開my.ini,在後面加上上面的參數,保存後重啟mysql服務就行了。
例如:#Enter a name for the binary log. Otherwise a default name will be used.
#log-bin=#Enter a name for the query log file. Otherwise a default name will be used.
#log=#Enter a name for the error log file. Otherwise a default name will be used.
log-error=#Enter a name for the update log file. Otherwise a default name will be used.
#log-update=
上面只開啟了錯誤日誌,要開其他的日誌就把前面的「#」去掉
查看命令:①show variables like 'log_%';查看所有的log命令
②show variables like 'log_bin';查看具體的log命令

㈡ 如何關閉MySQL日誌,刪除mysql日誌

刪除日誌:
執行:/usr/local/mysql/bin/mysql -u root -p
輸入密碼登錄後再執行:reset master;
再輸入:quit 退出mysql命令模式。

徹底禁用MySQL日誌:修改/etc/my.cnf 文件,

找到log-bin搜索=mysql-binbinlog_format=mixed再這兩行前面加上#,

將其注釋掉,再執行/etc/init.d/mysql restart即可。

或直接去目錄/usr/local/mysql/var/刪除日誌文件即可正常使用!

㈢ 如何查詢MySql日誌

1.首先確認你日誌是否啟用了
MySQL>show variables like 'log_bin';

2.如果啟用了,即ON那日誌文件就在MySQL的安裝目錄的data目錄下

3.怎樣知道當前的日誌
MySQL> show master status;

4.看二進制日誌文件用MySQLbinlog
shell>MySQLbinlog mail-bin.000001

或者
shell>MySQLbinlog mail-bin.000001 | tail 因為mail-bin.000001是二進制的日誌,所以想看日誌就需要用mysqlbinlog命令,將二進制文件轉換為日誌文件,下面詳細說說如何使用:上面已經說過如果啟用了日誌文件,那麼默認的日誌文件就在data目錄下(如果你沒有更改的話)進入存放日誌文件目錄,使用mysqlbinlog localhost-bin.000202 > new_file_name.log
命令,將目標文件保存為日誌文件,可指定保存路徑下
有個小技巧跟大家介紹下,我在准備轉換的時候發現日誌文件有2G多,尋思著為什麼mysql為什麼不把日誌按日誌定期的分多個文件放呢。結果發現mysql有個更好的方法,可以通過時間參數獲取某個時間段的數據,例子如下:mysqlbinlog --start-datetime="2010-11-20 00:00:00" --stop-datetime="2010-11-21 00:00:00"
[hx@localhost data]$ mysqlbinlog
mysqlbinlog Ver 3.0 for pc-linux-gnu at i686
By Monty and Sasha, for your professional use
This software comes with NO WARRANTY: This is free software,
and you are welcome to modify and redistribute it under the GPL licenseDumps a MySQL binary log in a format usable for viewing or for piping to
the mysql command line clientUsage: mysqlbinlog [options] log-files
-d, --database=name List entries for just this database (local log only).
-D, --disable-log-bin
Disable binary log. This is useful, if you enabled
--to-last-log and are sending the output to the same
MySQL server. This way you could avoid an endless loop.
You would also like to use it when restoring after a
crash to avoid plication of the statements you already
have. NOTE: you will need a SUPER privilege to use this
option.
-f, --force-read Force reading unknown binlog events.
-?, --help Display this help and exit.
-h, --host=name Get the binlog from server.
-o, --offset=# Skip the first N entries.
-p, --password[=name]
Password to connect to remote server.
-P, --port=# Use port to connect to the remote server.
-j, --position=# Deprecated. Use --start-position instead.
--protocol=name The protocol of connection (tcp,socket,pipe,memory).
-r, --result-file=name
Direct output to a given file.
-R, --read-from-remote-server
Read binary logs from a MySQL server
--open_files_limit=#
Used to reserve file descriptors for usage by this
program
-s, --short-form Just show the queries, no extra info.
-S, --socket=name Socket file to use for connection.
--start-datetime=name
Start reading the binlog at first event having a datetime
equal or posterior to the argument; the argument must be
a date and time in the local time zone, in any format
accepted by the MySQL server for DATETIME and TIMESTAMP
types, for example: 2004-12-25 11:25:56 (you should
probably use quotes for your shell to set it properly).
--stop-datetime=name
Stop reading the binlog at first event having a datetime
equal or posterior to the argument; the argument must be
a date and time in the local time zone, in any format
accepted by the MySQL server for DATETIME and TIMESTAMP
types, for example: 2004-12-25 11:25:56 (you should
probably use quotes for your shell to set it properly).
--start-position=# Start reading the binlog at position N. Applies to the
first binlog passed on the command line.
--stop-position=# Stop reading the binlog at position N. Applies to the
last binlog passed on the command line.
-t, --to-last-log Requires -R. Will not stop at the end of the requested
binlog but rather continue printing until the end of the
last binlog of the MySQL server. If you send the output
to the same MySQL server, that may lead to an endless
loop.
-u, --user=name Connect to the remote server as username.
-l, --local-load=name
Prepare local temporary files for LOAD DATA INFILE in the
specified directory.
-V, --version Print version and exit.Variables (--variable-name=value)
and boolean options {FALSE|TRUE} Value (after reading options)
--------------------------------- -----------------------------
database (No default value)
disable-log-bin FALSE
force-read FALSE
host (No default value)
offset 0
port 3306
position 4
read-from-remote-server FALSE
open_files_limit 64
short-form FALSE
socket (No default value)
start-datetime (No default value)
stop-datetime (No default value)
start-position 4
stop-position 18446744073709551615
to-last-log FALSE
user (No default value)
local-load (No default value)2009.09.30 檢查一個應用的問題的時候,發現通過 oracle 的 dblink 連接 mysql 進行更新等操作的時候,mysql 不會把操作的 sql 語句記錄到日誌文件里

㈣ 怎麼開啟mysql日誌功能

1)怎麼查看mysql是否啟用了日誌
mysql>show variables like 'log_bin';

2)怎樣知道當前的日誌
mysql> show master status;

3)如何查看當前的二進制日誌,可以使用mysqlbinlog的的工具,命令如下:
shell>mysqlbinlog mail-bin.000001(要寫絕對問題路徑d://)
或者shell>mysqlbinlog mail-bin.000001 | tail

4)mysql有以下幾種日誌:
錯誤日誌:
-log-err
查詢日誌:
-log
慢查詢日誌:
-log-slow-queries
更新日誌:
-log-update
二進制日誌:
-log-bin

在mysql的安裝目錄下,打開my.ini,在後面加上上面的參數,保存後重啟mysql服務就行了。
例如:
#Enter a name for the error
log file. Otherwise a default
name will be used.
log-error=err.log
#Enter a name for the query
log file. Otherwise a default name will be used.
#log=
#Enter a name for the slow
query log file. Otherwise a default name will be used.
#log-slow-queries=
#Enter a name for the update
log file. Otherwise a default name will be used.
#log-update=
#Enter a name for the binary
log. Otherwise a default name will be used.
#log-bin=
上面只開啟了錯誤日誌,要開其他的日誌就把前面的「#」去掉。

long_query_time =2--
這里設置慢日誌的最大實現是指執行超過多久的sql會被log下來,這里是2秒
log-slow-queries=slowqueris.log --將查詢返回較慢的語句進行記錄,這里設置慢日誌的名稱
log-queries-not-using-indexes
= nouseindex.log --就是字面意思,log下來沒有使用索引的query
5)下面是配置日誌的幾種方式,不一定全都要配置,請根據自身需求選擇性配置
log=mylog.log
--對所有執行語句進行記錄
log-error=log-error.log
log=log-query.log
log-queries-not-using-indexes
log-warnings=2
log-slow-queries=log-slow-query.log
log-update=log-update.log
long_query_time=2

㈤ 怎麼查看mysql日誌

MySQL的日誌文件模塊啟動後才會有日誌記錄。
開啟日誌服務:
在MY.INI里,MYSQLD項下添加log-bin=mysql。
如果只對某個庫進行日誌文件記錄,那麼再添加binlog-do-db=test,這樣就只記錄test資料庫的日誌,而放棄其他的。
添加完後,重新啟動MYSQL的服務,日誌文件開始工作了.

查看是否啟用了日誌命令:mysql>show variables like 'log_bin';
查看當前的日誌命令:mysql> show master status;
看二進制日誌文件用mysqlbinlog命令:shell>mysqlbinlog mail-bin.000001

㈥ MySQL都有哪些日誌

普通查詢日誌
二進制日誌
慢查詢日誌

Mysql錯誤日誌主要記錄Mysql實例每次啟動、停止的詳細信息,以及Mysql實例運行過程中產生的警告或者錯誤信息,與其它日誌不同,Mysql錯誤日誌必須開啟,無法關閉。
Mysql general log記錄了Mysql運行的所有操作,無論這些操作執行成功與否。另外還包括一些事件,例如客戶端連接斷開的一些信息,默認不開啟。
慢日誌記錄執行時間過程和沒有使用索引的查詢語句,報錯select、update、delete以及insert語句,慢日誌只會記錄執行成功的語句。
二進制日記記錄資料庫的變化情況,內容報錯資料庫所有的更新操作,ddl和dml。資料庫管理員可以通過二進制日誌查看資料庫過去某一時刻發生了哪些變化,必要時可以使用二進制日誌恢復資料庫。二進制文件內容為二進制信息,不可直接查看。

㈦ 如何查看mysql資料庫操作記錄日誌

1、首先確認你日誌是否啟用了mysql>show variables like 'log_bin'。

2、如果啟用了,即ON,那日誌文件就在mysql的安裝目錄的data目錄下。

3、怎樣知道當前的日誌mysql> show master status。

4、看二進制日誌文件用mysqlbinlog,shell>mysqlbinlog mail-bin.000001或者shell>mysqlbinlog mail-bin.000001 | tail,Windows 下用類似的。

㈧ 如何查看mysql資料庫操作記錄日誌

有時候我們會不小心對一個大表進行了 update,比如說寫錯了 where 條件......

此時,如果 kill 掉 update 線程,那回滾 undo log 需要不少時間。如果放置不管,也不知道 update 會持續多久。

那我們能知道 update 的進度么?



實驗

我們先創建一個測試資料庫:

那我們怎麼准確的這個倍數呢?

一種方法是靠經驗:update 語句的 where 中會掃描多少行,是否修改主鍵,是否修改唯一鍵,以這些條件來估算系數。

另一種方法就是在同樣結構的較小的表上試驗一下,獲取倍數。

這樣,我們就能准確估算一個大型 update 的進度了。

㈨ mysql如何記錄查看SQL命令錯誤日誌

mysql> show variables like '%error'; 錯誤日誌文件

閱讀全文

與mysql命令日誌相關的資料

熱點內容
微信位置可以加密嗎 瀏覽:466
演算法蠻力法 瀏覽:436
隨機排練命令 瀏覽:147
python多進程並發 瀏覽:41
安卓軟體安裝如何躲避安全檢測 瀏覽:647
奇幻潮翡翠台源碼百度雲盤 瀏覽:187
什麼軟體可以免費pdf轉word 瀏覽:15
php正則表達式大全 瀏覽:394
androidntp時間 瀏覽:299
輪機長命令簿英文 瀏覽:148
oppo鈴聲設置被加密怎麼處理 瀏覽:548
粵苗app圖形驗證碼怎麼填 瀏覽:899
管家婆架設雲伺服器 瀏覽:254
php的登錄界面代碼 瀏覽:997
php開發客戶端 瀏覽:998
theisle測試服怎麼搜伺服器 瀏覽:447
廣播PDF 瀏覽:218
單片機編程300例匯編百度 瀏覽:35
騰訊雲連接不上伺服器 瀏覽:223
不能用來表示演算法的是 瀏覽:861