OSX MySQL Configuration
Caveats: I have used Home brew to install MySQL on Mavericks
Installation:
brew install mysql
Once installed run these steps:
unset TMPDIR
mysql_install_db --verbose --user=`whoami` --basedir="$(brew --prefix mysql)" --datadir=/usr/local/var/mysql --tmpdir=/tmp
Then set up a symlink to the socket used by MySQL:
sudo mkdir /var/mysql
sudo ln -s /tmp/mysql.sock /var/mysql/mysql.sock
This installs MySQL and links it so that the binary
/usr/local/bin/mysql
is a link to
/usr/local/Cellar/mysql/5.6.16/bin/mysql
So once set up you may want to configure the environment.
Do this by creating a my.cnf file (or editing the one) in
/usr/local/Cellar/mysql/5.6.16/my.cnf
You can then adjust the various options to either match production or to manage the memory used by your local installation.
Here is an example taken straight from http://www.robbyonrails.com/articles/2013/11/24/reducing-mysqls-memory-usage-on-os-x-mavericks
so they will need to be updated to reflect your needs:
# MySQL overrides
[mysqld]
max_connections = 10
key_buffer_size = 16K
max_allowed_packet = 1M
table_open_cache = 4
sort_buffer_size = 64K
read_buffer_size = 256K
read_rnd_buffer_size = 256K
net_buffer_length = 2K
thread_stack = 128K
Once edited restart mysql:
mysql-server restart
Other tasks:
One things you should do is to set a password for the root user
To do so, start the server, then issue the following commands:
/usr/local/opt/mysql/bin/mysqladmin -u root password 'new-password'
/usr/local/opt/mysql/bin/mysqladmin -u root -h <yourhostname> password 'new-password'
Alternatively you can run:
/usr/local/opt/mysql/bin/mysql_secure_installation
This will run through setting passwords, removing users, test data etc
Some other handy MySQL commands:
# Is MySQL running?
mysqladmin -u root -p ping
For day to day management and interaction with MySQL I use MySQL Workbench