mysql的日志怎么用,mysql中,關(guān)于各類日志

怎么開啟mysql日志功能

1)怎么查看mysql是否啟用了日志

成都創(chuàng)新互聯(lián)公司-專業(yè)網(wǎng)站定制、快速模板網(wǎng)站建設(shè)、高性價比綦江網(wǎng)站開發(fā)、企業(yè)建站全套包干低至880元,成熟完善的模板庫,直接使用。一站式綦江網(wǎng)站制作公司更省心,省錢,快速模板網(wǎng)站建設(shè)找我們,業(yè)務(wù)覆蓋綦江地區(qū)。費用合理售后完善,10多年實體公司更值得信賴。

mysqlshow variables like 'log_bin';

2)怎樣知道當(dāng)前的日志

mysql show master status;

3)如何查看當(dāng)前的二進制日志,可以使用mysqlbinlog的的工具,命令如下:

shellmysqlbinlog mail-bin.000001(要寫絕對問題路徑 d://)

或者shellmysqlbinlog mail-bin.000001 | tail

4)mysql有以下幾種日志:

錯誤日志:????

-log-err

查詢?nèi)罩荆????

-log

慢查詢?nèi)罩????

-log-slow-queries

更新日志:?????

-log-update

二進制日志:?

-log-bin

在mysql的安裝目錄下,打開my.ini,在后面加上上面的參數(shù),保存后重啟mysql服務(wù)就行了。

例如:

#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--

這里設(shè)置慢日志的最大實現(xiàn)是指執(zhí)行超過多久的sql會被log下來,這里是2秒

log-slow-queries=slowqueris.log --將查詢返回較慢的語句進行記錄,這里設(shè)置慢日志的名稱

log-queries-not-using-indexes

= nouseindex.log --就是字面意思,log下來沒有使用索引的query

5)下面是配置日志的幾種方式,不一定全都要配置,請根據(jù)自身需求選擇性配置

log=mylog.log

--對所有執(zhí)行語句進行記錄

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數(shù)據(jù)庫日志怎么看

MySQL的日志文件模塊啟動后才會有日志記錄。

開啟日志服務(wù):

在MY.INI里,MYSQLD項下添加log-bin=mysql。

如果只對某個庫進行日志文件記錄,那么再添加binlog-do-db=test,這樣就只記錄test數(shù)據(jù)庫的日志,而放棄其他的。

添加完后,重新啟動MYSQL的服務(wù),日志文件開始工作了.

查看是否啟用了日志命令:mysqlshow variables like 'log_bin';

查看當(dāng)前的日志命令:mysql show master status;

看二進制日志文件用mysqlbinlog命令:shellmysqlbinlog mail-bin.000001

mysql如何使用事物日志ib

,查看Mysqld(/var/log/mysqld.log)日志,發(fā)現(xiàn)以下錯誤:

InnoDB: Error: log file /usr/local/mysql/data/ib_logfile0 is of different size 0

5242880 bytes

InnoDB: than specified in the .cnf file 0 104857600 bytes!

030826 1:42:15 Can't init databases

030826 1:42:15 Aborting

2,解決辦法

"

If you want to change the number or the size of your InnoDB log files, you

have to shut down MySQL and make sure that it shuts down without errors.

Then copy the old log files into a safe place just in case something went

wrong in the shutdown and you will need them to recover the database. Delete

then the old log files from the log file directory, edit my.cnf, and start

MySQL again. InnoDB will tell you at the startup that it is creating new log

files.

"

在你修改my.cnf的innodb_log_file_size參數(shù)前,請先停止mysql服務(wù)程序的運行(mysql的停止沒有出現(xiàn)任何錯誤),并把/var/lib/mysql目錄下的ib_logfile0、ib_logfile1、ib_logfile2等之類的文件移除到一個安全的地方(舊日志文件的保留是為了防止意外的出現(xiàn)),以便Mysql重啟后可以將新的ib_logfile0之類日志文件生成到/var/lib/mysql目錄下。如果沒有什么意外,舊的日志文件可以刪除。

mysql日志文件怎么用?

my.cnf 這個mysql日志分:錯誤日志,二進制日志,慢查詢?nèi)罩荆D(zhuǎn)儲日志,每一種都有不同的作用,查看全局變量,顯示為on即為開啟,顯示為off即為關(guān)閉,具體怎么用,不是一言兩語能說清楚的。建議去51cto里查看相關(guān)技術(shù)博客

MySQL軟件的日志操作介紹

方法/步驟

1、首先,登陸mysql后,執(zhí)行sql語句:

show

variables

like

'log_bin';

查看是否日志開啟,詳細結(jié)果如圖:

2、#錯誤日志

log-error

開啟方式:

在my.ini的[mysqld]選項下:

添加代碼:

log-error=E:\log-error.txt

記錄內(nèi)容:

主要是記錄啟動、運行或停止mysqld時出現(xiàn)的致命性問題,都是系統(tǒng)級的錯誤記錄如圖:

3、#查詢?nèi)罩?/p>

log

開啟方式:

在my.ini的[mysqld]選項下:

添加代碼:

log=E:/mysql_log.txt

記錄內(nèi)容:

主要是記錄數(shù)據(jù)庫建立的客戶端連接和執(zhí)行的語句如圖:

4、#二進制日志

log-bin

開啟方式:

在my.ini的[mysqld]選項下:

添加代碼:

log-bin=E:/mysql_log_bin

記錄內(nèi)容:

主要是記錄所有的更改數(shù)據(jù)的語句,可使用mysqlbinlog命令恢復(fù)數(shù)據(jù)。如圖:

#慢日志

log-slow-queries

開啟方式:

在my.ini的[mysqld]選項下:

添加代碼:

long_query_time

=1

(設(shè)定慢查詢的標(biāo)準(zhǔn),單位是s/秒)

log-slow-queries=

E:/mysql_log_slow.txt

記錄內(nèi)容:

主要是記錄所有執(zhí)行時間超過long_query_time的查詢或沒有使用索引的查詢?nèi)鐖D:

以上就是專題欄小編帶來的mysql中文版教程,更多教程請看“”

新聞名稱:mysql的日志怎么用,mysql中,關(guān)于各類日志
文章來源:http://www.muchs.cn/article14/phjjde.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供品牌網(wǎng)站制作、網(wǎng)站設(shè)計公司、企業(yè)網(wǎng)站制作、建站公司、微信公眾號、域名注冊

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)

成都網(wǎng)頁設(shè)計公司