用 Homebrew 安裝 Percona (MySQL)

安裝

$ brew install percona-server
$ unset TMPDIR
$ mysql_install_db --verbose --user=`whoami` --basedir="$(brew --prefix percona-server)" --datadir=/usr/local/var/percona --tmpdir=/tmp

Launch Agent

如果開機就要啟動,需設定 Launch Agent. 如果已有 ~/Library/LaunchAgents 則不需 mkdir.

$ mkdir -p ~/Library/LaunchAgents
$ cp /usr/local/opt/percona-server/homebrew.mxcl.percona-server.plist ~/Library/LaunchAgents/
$ launchctl load -w ~/Library/LaunchAgents/homebrew.mxcl.percona-server.plist

開防火牆

如 Mac OS X 有開防火牆,需允許 mysqld 傳入連線

改 root 密碼

$ /usr/local/opt/percona-server/bin/mysqladmin -u root password 'new-password'

設定 my.cnf

可以從內建的樣板來修改

sudo cp $(brew --prefix percona-server)/support-files/my-small.cnf /etc/my.cnf

在 my.cnf 中設定 InnoDB (XtraDB),uncomment 樣板設定即可

# Uncomment the following if you are using InnoDB tables
#innodb_data_home_dir = /usr/local/var/percona
#innodb_data_file_path = ibdata1:10M:autoextend
#innodb_log_group_home_dir = /usr/local/var/percona
# You can set .._buffer_pool_size up to 50 - 80 %
# of RAM but beware of setting memory usage too high
#innodb_buffer_pool_size = 16M
#innodb_additional_mem_pool_size = 2M
# Set .._log_file_size to 25 % of buffer pool size
#innodb_log_file_size = 5M
#innodb_log_buffer_size = 8M
#innodb_flush_log_at_trx_commit = 1
#innodb_lock_wait_timeout = 50

啟動 mysql 的 script

$ mysql.server {start|stop|restart|reload|force-reload|status}