LoginSignup
222
187

More than 5 years have passed since last update.

mac MySQL ターミナル 自動起動

Posted at

ターミナルを立ち上げるたびに、

$ mysql.server start

と入力するのがめんどくさいので、自動起動の方法を記す。

MySQLはhomebrewでインストール。

$ brew update
$ brew install mysql

インストールが完了したら、

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

と表示されるが、こちらは使わずに、launchctlのマネージャーにhomebrew-servicesを使用する。

公式サイトはこちら。
https://github.com/Homebrew/homebrew-services

READMEに従ってインストール。

$ brew tap homebrew/services

MySQLを自動起動にする。

$ brew services start mysql

==> Successfully started `mysql` (label: homebrew.mxcl.mysql)

これだけ。

自動起動を止めたい時は、

$ brew services stop mysql

Stopping `mysql`... (might take a while)
==> Successfully stopped `mysql` (label: homebrew.mxcl.mysql)

一覧を取得したい。

$ brew services list

Name       Status  User   Plist
mysql      started ------ /Users/------/Library/LaunchAgents/homebrew.mxcl.mysql.plist
postgresql started ------ /Users/------/Library/LaunchAgents/homebrew.mxcl.postgresql.plist

以上。

222
187
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
222
187