- 追加された行はこの色です。
- 削除された行はこの色です。
#author("2017-01-29T11:51:49+09:00","default:wikiwriter","wikiwriter")
#author("2017-02-20T15:02:53+09:00","default:wikiwriter","wikiwriter")
&tag(Homebrew/mysql);
*目次 [#id978086]
#contents
*参考情報 [#r126b57e]
-[[Homebrew]]
-[[./古い情報]]
*5.6のインストール [#u945690f]
-普通にインストールすると、5.6が入る
brew install mysql
-設定ファイルをコピー。mysql --help | grep my.cnfで表示された場所に置く。/etc/my.cnf /etc/mysql/my.cnf /usr/local/etc/my.cnf ~/.my.cnfだったので、/usr/local/etc/my.cnf にした。
cp /usr/local/Cellar/mysql/5.6.10/support-files/my-default.cnf /usr/local/etc/my.cnf
-データベース初期化。
mysql_install_db --verbose --user=`whoami` --basedir="$(brew --prefix mysql)" --datadir=/usr/local/var/mysql --tmpdir=/tmp
**自動起動 [#pabdf864]
-/usr/local/opt/mysql/homebrew.mxcl.httpd.plistを編集。KeepAliveをfalseにしておく。falseじゃないと、mysql.server start/stop/restartが上手く動かない(PIDファイルがどうのこうのいわれる)。
-plistを登録する。
ln -sfv /usr/local/opt/mysql/*.plist ~/Library/LaunchAgents
launchctl load -w ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist
**サーバー起動 [#wbecb597]
-mysql.serverコマンドで操作できる。
mysql.server start
**rootのパスワード設定 [#s0cda662]
-mysqladminを使う
mysqladmin -uroot password
*5.5のインストール(homebrew-core) [#g8b8b1d1]
**インストール [#c807f7c9]
-2017/01/27(金)現在、coreで複数バージョンのサポートが始まっている模様。
-以下のようにすれば過去のバージョンをインストールすることができる(5.5.49がインストールされる)
brew install mysql@5.5
-以下のインストラクションが表示される。
#pre{{
==> Caveats
A "/etc/my.cnf" from another install may interfere with a Homebrew-built
server starting up correctly.
To connect:
/usr/local/opt/mysql@5.5/bin/mysql -uroot
To have launchd start mysql@5.5 now and restart at login:
brew services start mysql@5.5
Or, if you don't want/need a background service you can just run:
/usr/local/opt/mysql55/bin/mysql.server start
==> Summary
}}
**my.cnfの作成 [#t1e50ef4]
-my.cnfの作成。/usr/locdal/mysql55/bin/mysql --helpによると次の場所からmy.cnfは読み込まれる
/etc/my.cnf /etc/mysql/my.cnf /usr/local/etc/my.cnf ~/.my.cnf
-ひな形をコピー
$ cp /usr/local/Cellar/mysql@5.5/5.5.49/support-files/my-medium.cnf /usr/local/etc/my.cnf
-文字コードをUTF-8にするなど修正。
#pre{{
[client]
default-character-set=utf8
[mysqldump]
default-character-set=utf8
[mysql]
default-character-set=utf8
[mysqld]
character-set-server=utf8
}}
**自動起動設定 [#ge6090ec]
- plistをlink
ln -svf /usr/local/opt/mysql@5.5/*.plist ~/Library/LaunchAgents
-launchctlに登録
launchctl load ~/Library/LaunchAgents/homebrew.mxcl.mysql@5.5.plist
**その他 [#m8385b46]
-Homebrew-versionsでは /usr/local/var/mysql55がデータフォルダだったのに対し、core版では /usr/local/var/mysqlがデータフォルダになっている(以下のコマンドで確認できる)。
mysql -uUSER -p -e 'SHOW VARIABLES WHERE Variable_Name LIKE "%dir"'
-一端サービスをunloadしてからフォルダを移動した。
launchctl unload ~/Library/LaunchAgents/homebrew.mxcl.mysql@5.5.plist
cd /usr/local/var
mv mysql mysql.new
mv mysql55 mysql
-keg-onlyパッケージなのでlinkするとbrew doctorで警告が表示される。以下のフォルダをPATHに追加しておくと良いかも。
#pre{{
/usr/local/opt/mysql@5.5/bin
}}
*5.5.40のインストール(homebrew-versionsを仕様) [#hb6d6f92]
**インストール [#ddcf1627]
-以下のコマンドでインストール。
brew tap homebrew/versions
brew install mysql55
-以下のインストラクションが表示される。
#pre{{
A "/etc/my.cnf" from another install may interfere with a Homebrew-built
server starting up correctly.
To connect:
mysql -uroot
This formula is keg-only, which means it was not symlinked into /usr/local.
Conflicts with mysql, mariadb, percona-server, mysql-cluster, etc.
Generally there are no consequences of this for you. If you build your
own software and it requires this formula, you'll need to add to your
build variables:
LDFLAGS: -L/usr/local/opt/mysql55/lib
CPPFLAGS: -I/usr/local/opt/mysql55/include
To have launchd start mysql55 at login:
ln -sfv /usr/local/opt/mysql55/*.plist ~/Library/LaunchAgents
Then to load mysql55 now:
launchctl load ~/Library/LaunchAgents/homebrew.mxcl.mysql55.plist
Or, if you don't want/need launchctl, you can just run:
mysql.server start
}}
**my.cnfの作成 [#s5e10010]
-my.cnfの作成。/usr/locdal/mysql55/bin/mysql --helpによると次の場所からmy.cnfは読み込まれる
/etc/my.cnf /etc/mysql/my.cnf /usr/local/etc/my.cnf ~/.my.cnf
-ひな形をコピー
$ cp /usr/local/Cellar/mysql55/5.5.30/support-files/my-medium.cnf /usr/local/etc/my.cnf
-文字コードをUTF-8にするなど修正。
#pre{{
[client]
default-character-set=utf8
[mysqldump]
default-character-set=utf8
[mysql]
default-character-set=utf8
[mysqld]
character-set-server=utf8
}}
** 自動起動(手動)[#f03ff32c]
- plistをlink
ln -sfv /usr/local/opt/mysql55/*.plist ~/Library/LaunchAgents
-launchctlに登録
launchctl load ~/Library/LaunchAgents/homebrew.mxcl.mysql55.plist
** コマンドを使用可能に [#m2044487]
- linkする
brew link mysql55 --force
**パスワードの変更 [#m04857d5]
-mysqladminで設定しておく
mysqladmin -uroot password