[Mac] MySQL を Homebrew でインストール

Pocket

Mac に MySQL を Homebrew でインストールしました。(最終更新日:2013/07/14)

Homebrewのインストールはこちらから
[Mac] Homebrew をインストール(ついでにGitもインストール)

MySQL のインストール

% brew install mysql
==> Downloading https://downloads.sf.net/project/machomebrew/Bottles/mysql-5.6.12.mountain_lion.bottle.tar.gz
######################################################################## 100.0%
==> Pouring mysql-5.6.12.mountain_lion.bottle.tar.gz
==> /usr/local/Cellar/mysql/5.6.12/bin/mysql_install_db --verbose --user=bakorer --basedir=/usr/local/Cellar/mysql/5.6.12 --datadir=/usr/local/var/mysql --tmpdir=/tmp
==> Caveats
A "/etc/my.cnf" from another install may interfere with a Homebrew-built
server starting up correctly.
 
To connect:
    mysql -uroot
 
To have launchd start mysql at login:
    ln -sfv /usr/local/opt/mysql/*.plist ~/Library/LaunchAgents
Then to load mysql now:
    launchctl load ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist
Or, if you don't want/need launchctl, you can just run:
    mysql.server start
==> Summary
/usr/local/Cellar/mysql/5.6.12: 9363 files, 353M

MySQLの自動起動設定

% ln -sfv /usr/local/opt/mysql/*.plist ~/Library/LaunchAgents
% launchctl load ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist

MySQLを手動で起動したい場合は…

mysql.server start

root ユーザーでログインする

% mysql -u root
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.6.12 Source distribution
 
Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
 
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
 
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
 
mysql> show variables like 'character_set%';
+--------------------------+------------------------------------------------------+
| Variable_name            | Value                                                |
+--------------------------+------------------------------------------------------+
| character_set_client     | utf8                                                 |
| character_set_connection | utf8                                                 |
| character_set_database   | utf8                                                 |
| character_set_filesystem | binary                                               |
| character_set_results    | utf8                                                 |
| character_set_server     | utf8                                                 |
| character_set_system     | utf8                                                 |
| character_sets_dir       | /usr/local/Cellar/mysql/5.6.12/share/mysql/charsets/ |
+--------------------------+------------------------------------------------------+
8 rows in set (0.01 sec)

カンタンですね!

  1. コメントはまだありません。

  1. トラックバックはまだありません。