Tuesday, 6 September 2005

mySQL Database Engine

The SQL database of choice for most real-world purposes (i.e., for your average database needs). Bit finicky on occasion, but quite good overall. And I loathe databases.

3-Step Guide for mySQL on Mac OS X:

  • get Fink
  • sudo apt-get install mysql
  • daemonic enable mysql

...and then sudo vi /Library/StartupItems/daemonic-mysql to add a stop) clause, and sudo vi /sw/var/mysql/my.cnf to edit the config.

Lockdown in a nutshell:

;/etc/my.cnf
[mysqld]
port=3306
set-variable = key_buffer=8M
set-variable = max_allowed_packet=1M
set-variable = thread_stack=128K
bind-address = 127.0.0.1
DROP DATABASE test;
use mysql;
DELETE FROM db WHERE Db like 'test%';
DELETE FROM user WHERE Host = '%';
DELETE FROM user WHERE User = '';
UPDATE user SET Password = password('mypassword') WHERE User = 'root';
FLUSH PRIVILEGES;

launchd .plist

...for the DarwinPorts package, kept here for future reference:

cat /Library/LaunchDaemons/com.mysql.Mysql.plist
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
        <key>Label</key>
        <string>com.mysql.Mysql</string>
        <key>ProgramArguments</key>
        <array>
                <string>/opt/local/bin/mysqld_safe</string>
                <string>-user mysql</string>
        </array>
        <key>RunAtLoad</key>
        <true/>
        <key>ServiceDescription</key>
        <string>Mysql 4.1.12 Database Server</string>
        <key>UserName</key>
        <string>mysql</string>
        <key>WorkingDirectory</key>
        <string>/opt/local/var/db/mysql</string>
</dict>
</plist>