Friday, April 25, 2008

MySQL Query Logging in MAMP

MAMP is a LAMP environment in an application for OS X. It saves a lot of time getting a local development environment going especially if you're changing computers often. If you use MAMP it may not be immediately straight-forward how to enable MySQL Query Logging since it has an executable that starts and stops MySQL and Apache and it uses a separate MySQL socket.

Why use sql query logging? A great way to learn about or optimize an application is to watch how it interacts with a database. You can issue a command from within an application and see exactly what commands it triggers to MySQL. This is extremely helpful when trying to get a handle on an application that utilizes an abstract and/or highly normalized data structure.

First, a couple warnings. MySQL Query Logging should only be used in development environments. The log files it creates could potentially become humongous in size. Also, it greatly reduces MySQL performance while it is running.

1) Stop MySQL with this command from Terminal

/Applications/MAMP/Library/bin/mysqladmin -u root -proot --socket=/Applications/MAMP/tmp/mysql/mysql.sock shutdown


2) Issue this command in Terminal

/Applications/MAMP/Library/bin/mysqld_safe --port=8889 --socket=/Applications/MAMP/tmp/mysql/mysql.sock --lower_case_table_names=0 --pid-file=/Applications/MAMP/tmp/mysql/mysql.pid --log-error=/Applications/MAMP/logs/mysql_error_log --log=/tmp/mysqlLOG.lg &


You can monitor the output of mysql in Terminal with this command:

sudo tail -f /tmp/mysqlLOG.lg

As you issue commands to your local MySQL server you will see them generated instantly in a continuous scroll in a terminal window.

MySQL Query Logging will run until the next to you stop MAMP. It will not do query logging unless you issue the start command as above and include the --log= directive.

Sunday, March 2, 2008

If history had been taught like this...

I think I would have ended up with better grades...

Friday, December 21, 2007

happy holidays all!


saw this on my friend's blog and thought i'd spread the love...be patient it's fun!

Wednesday, November 28, 2007

Other People's Lives

This interested me enough that I figured it was worth posting:
Adoption

Two reasons:
1 - I am korean
2 - I am adopted

Wednesday, October 24, 2007

Simplicity

You probably already know that the singular destination on the web for learning about some of the world's most interesting ideas and people is the TED website. One of our favorite talks there is by John Maeda, the keen observer and charming advocate of simplicity not just in design and technology but in life as a whole.

Labels: , ,