成都网站建设设计

将想法与焦点和您一起共享

mysql怎么运用日志,怎么查看mysql的运行日志

如何在mysql中记录sql日志记录

1、WIN的话,在安装目录下,找到my.ini文件

10余年的湖口网站建设经验,针对设计、前端、开发、售后、文案、推广等六对一服务,响应快,48小时及时工作处理。成都全网营销的优势是能够根据用户设备显示端的尺寸不同,自动调整湖口建站的显示方式,使网站能够适用不同显示终端,在浏览器中调整网站的宽度,无论在任何一种浏览器上浏览网站,都能展现优雅布局与设计,从而大程度地提升浏览体验。创新互联从事“湖口网站设计”,“湖口网站推广”以来,每个客户项目都认真落实执行。

查[mysqld]区段,添加日志的配置

比如说:[mysqld]log=C:/temp/mysql.log

log_slow_queries=C:/temp/mysql_slow.log

long_query_time=1

log指示日志文件存放目录

log_slow_queries指示记录执行时间长的sql日志目录;

long_query_time指示多长时间算是执行时间。

2、LINUX下的话,文件名为my.cnf

Linux下这些配置项其实都有的,只是被注释掉了,删去注释符#之类的就可以了。

你不愿删注释符,愿意的话手工再添加也可以……

然后重启mysql服务就OK了。

怎么开启mysql日志功能

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

mysqlshow variables like 'log_bin';

2)怎样知道当前的日志

mysql show master status;

3)如何查看当前的二进制日志,可以使用mysqlbinlog的的工具,命令如下:

shellmysqlbinlog mail-bin.000001(要写绝对问题路径 d://)

或者shellmysqlbinlog 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中记录SQL日志记录

查了一下资料,My SQL可以用下面方法跟踪sql 语句,以下方法以Windows平台为例,linux雷同:

1 配置my.ini文件(在安装目录,linux下文件名为my.cnf

查找到[mysqld]区段,增加日志的配置,如下示例:[mysqld]log=C:/temp/mysql.log

log_slow_queries=C:/temp/mysql_slow.log

long_query_time=1

log指示日志文件存放目录;

log_slow_queries指示记录执行时间长的sql日志目录;

long_query_time指示多长时间算是执行时间长,单位s。

Linux下这些配置项应该已经存在,只是被注释掉了,可以去掉注释。但直接添加配置项也OK啦。

2 重新启动mysql服务。注意事项:A日志存放目录必须提前存在,否则不能记录日志。这里也局势C:/temp目录必须已经存在

B 日志文件是linux格式的文本,建议用ultraEdit打开,转换为dos格式查看(否则没有换行,看不懂的)

C 服务在启动状态下不能删除日志文件,否则就无法记录sql语句了。

D 不能用ultraEdit直接清除文件内容后保存,否则也记录不下来了。需要重启服务,如果ultraEdit保存了.bak,后记录到此文件中。

E 可以用notepad清除文本后保存,可以继续记录日志。

mysql如何使用事物日志ib

,查看Mysqld(/var/log/mysqld.log)日志,发现以下错误:

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参数前,请先停止mysql服务程序的运行(mysql的停止没有出现任何错误),并把/var/lib/mysql目录下的ib_logfile0、ib_logfile1、ib_logfile2等之类的文件移除到一个安全的地方(旧日志文件的保留是为了防止意外的出现),以便Mysql重启后可以将新的ib_logfile0之类日志文件生成到/var/lib/mysql目录下。如果没有什么意外,旧的日志文件可以删除。


网站题目:mysql怎么运用日志,怎么查看mysql的运行日志
标题来源:http://chengdu.cdxwcx.cn/article/dscsssi.html