查看MySQL数据库日志

查看mysql数据库日志可以查看对数据库的操作记录。 mysql日志文件默认没有产生,需要做如下配置:

打开mysql的配置文件

sudo vi /etc/mysql/mysql.conf.d/mysqld.cnf

修改配置文件的第68、69行,将#去掉,保存退出

 66 # Be aware that this log type is a performance killer.
 67 # As of 5.1 you can enable the log at runtime!
 68 general_log_file        = /var/log/mysql/mysql.log
 69 general_log             = 1
 70 #
 71 # Error log - should be very few entries.

重启mysql服务: 

sudo service mysql restart

使用如下命令打开mysql日志文件:

tail -f /var/log/mysql/mysql.log  # 可以实时查看数据库的日志内容

猜你喜欢

转载自blog.csdn.net/Best_fish/article/details/83245359