Friday, October 26, 2012

MySQL Query Log on Mac

Create and edit /etc/my.conf:
> sudo vi /etc/my.cnf
Add following two lines:
[mysqld]
log=/var/log/mysql-query.log
Create the log file:
> sudo touch /var/log/mysql-query.log
> sudo chmod 666 /var/log/mysql-query.log
Restart MySQL:
> sudo /usr/local/mysql/support-files/mysql.server stop
> sudo /usr/local/mysql/support-files/mysql.server start
Execute an SQL statement:
> mysql -u root -e "select 1;"
Check log file:
> cat /var/log/mysql-query.log
To check log file location:
> mysqld --verbose --help | grep ^log
Acknowledgement: http://matthew.mceachen.us/

No comments:

Post a Comment