How to log MySQL queries on OS X


The default MySQL installer for OS X also includes a startup item that is added to the Mac System Properties thru which you start and stop MySQL. For development purposes, I needed to be able to tail the query log. According to the documentation, you can pass –log=path-to-log-file to the startup script, or add a log entry to the [mysqld] section of /etc/my.cnf file. The latter is the easiest way of creating a query log on OS X. Here are the steps that you need to follow:

  1. Create the file /etc/my.cnf (if you already don’t have one) and add the following lines:
    [mysqld]
    log=/var/log/mysqld.log
  2. su (become root)
  3. cd /var/log
  4. touch mysqld.log
  5. chmod 777 /var/log/mysqld.log
  6. Restart MySQL
Now you should be able to tail -f /var/log/mysqld.log

2 Responses to “How to log MySQL queries on OS X”

  1. Paul Hepworth Says:

    Thanks much! I was surprised that my.cnf was nonexistent all this time. A sql log is pretty helpful. :)

  2. vigo Says:

    kool! nice tip! thanx

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s


Follow

Get every new post delivered to your Inbox.