Saturday, February 12, 2011

Set MySQL Server System Variables on Mac OS X

Using MySQL and Java? Check out an easier way: Yank

If you need to set a system variable for the MySQL server, it's done by adding a name-value pair in a file called my.cnf. Where is my.cnf you're wondering? MySQL will look inside the /etc for "my.cnf" file. This file does not exist by default. The following steps describe how to create the my.cnf file used to confugure MySQL.

Step 1: Log into mysql. Fire up the terminal and enter:
/usr/local/mysql/bin/mysql -u root -p
Edit path and user appropriately.

Step 2: View MYSQL's current values:
show variables;
I'm interested in overriding the ft_min_word_len variable, and I see it's currently set to 4.

Step 3: Create /etc/my.cnf:
sudo vim /etc/my.cnf
and add (for example):

[mysqld]
default-time-zone='+00:00'
ft_min_word_len=1

to the file. Exit vim (esc :x).

Step 4: Restart MYSQL:
sudo /Library/StartupItems/MySQLCOM/MySQLCOM restart

Step 5: Log into MYSQL again and verify the change occured.

Piece of cake!!!


References

MySQL 5.5 system variables
The MySQL Configuration File


See also: Uninstall MySQL on Mac OS X
And also: Install MySQL on Mac OS X
And also: Installing and Running Tomcat on Mac OS X
And also: My Mac OS X MySQL Cheat Sheet

No comments: