㈠ 如何开启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'; 错误日志文件