LoginSignup
7
7

More than 5 years have passed since last update.

macにHomebrewでMySQLをインストールする

Posted at

0.環境

 OS X EI Capitan バージョン10.11.5

1.Homebrewをインストール

 まず肝心のHomebrewが入ってなかったのでインストール。
 URLは変更になるみたいですので、この記事を書いてる時は以下でしたが、都度確認が必要なようです。

/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

 結果:

==> This script will install:
/usr/local/bin/brew
/usr/local/Library/...
/usr/local/share/doc/homebrew
/usr/local/share/man/man1/brew.1
/usr/local/share/zsh/site-functions/_brew
/usr/local/etc/bash_completion.d/brew
==> The following directories will be made group writable:
/usr/local/.
/usr/local/bin
==> The following directories will have their owner set to admin:
/usr/local/.
/usr/local/bin
==> The following directories will have their group set to admin:
/usr/local/.
/usr/local/bin

Press RETURN to continue or any other key to abort
==> /usr/bin/sudo /bin/chmod g+rwx /usr/local/. /usr/local/bin
Password:
==> /usr/bin/sudo /usr/sbin/chown admin /usr/local/. /usr/local/bin
==> /usr/bin/sudo /usr/bin/chgrp admin /usr/local/. /usr/local/bin
==> /usr/bin/sudo /bin/mkdir /Library/Caches/Homebrew
==> /usr/bin/sudo /bin/chmod g+rwx /Library/Caches/Homebrew
==> /usr/bin/sudo /usr/sbin/chown admin /Library/Caches/Homebrew
==> Downloading and installing Homebrew...
remote: Counting objects: 491, done.
remote: Compressing objects: 100% (445/445), done.
remote: Total 491 (delta 27), reused 309 (delta 17), pack-reused 0
Receiving objects: 100% (491/491), 770.89 KiB | 40.00 KiB/s, done.
Resolving deltas: 100% (27/27), done.
From https://github.com/Homebrew/brew
 * [new branch]      master     -> origin/master
HEAD is now at 2cd81e5 update: pop the stash more quietly
==> Tapping homebrew/core
Cloning into '/usr/local/Library/Taps/homebrew/homebrew-core'...
remote: Counting objects: 3714, done.
remote: Compressing objects: 100% (3596/3596), done.
remote: Total 3714 (delta 13), reused 2396 (delta 9), pack-reused 0
Receiving objects: 100% (3714/3714), 2.89 MiB | 23.00 KiB/s, done.
Resolving deltas: 100% (13/13), done.
Checking connectivity... done.
Tapped 3592 formulae (3,740 files, 9.0M)
==> Installation successful!
==> Next steps
Run `brew help` to get started
Further documentation: https://git.io/brew-docs
==> Homebrew has enabled anonymous aggregate user behaviour analytics
Read the analytics documentation (and how to opt-out) here:
  https://git.io/brew-analytics

 途中、管理者ユーザのパスワードを求められただけで、スムーズにインストールできました。

2.MySQLをインストール

brew install mysql

 結果:

==> Installing dependencies for mysql: openssl
==> Installing mysql dependency: openssl
==> Downloading https://homebrew.bintray.com/bottles/openssl-    1.0.2h_1.el_capitan
########################################################################     100.0%
==> Pouring openssl-1.0.2h_1.el_capitan.bottle.tar.gz
==> Caveats
A CA file has been bootstrapped using certificates from the system
keychain. To add additional certificates, place .pem files in
  /usr/local/etc/openssl/certs

and run
  /usr/local/opt/openssl/bin/c_rehash

This formula is keg-only, which means it was not symlinked into     /usr/local.

Apple has deprecated use of OpenSSL in favor of its own TLS and crypto     libraries

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/openssl/lib
    CPPFLAGS: -I/usr/local/opt/openssl/include

==> Summary
🍺  /usr/local/Cellar/openssl/1.0.2h_1: 1,691 files, 12M
==> Installing mysql
==> Downloading https://homebrew.bintray.com/bottles/mysql-    5.7.13.el_capitan.bot
########################################################################     100.0%
==> Pouring mysql-5.7.13.el_capitan.bottle.tar.gz
==> /usr/local/Cellar/mysql/5.7.13/bin/mysqld --initialize-insecure --    user=admin
==> Caveats
We've installed your MySQL database without a root password. To secure it     run:
    mysql_secure_installation

To connect run:
    mysql -uroot

To have launchd start mysql now and restart at login:
  brew services start mysql
Or, if you don't want/need a background service you can just run:
  mysql.server start
==> Summary
🍺  /usr/local/Cellar/mysql/5.7.13: 13,344 files, 445.0M

 ビールの絵文字が出る箇所があり、なんだや?って思ってたらそのタイミングで数分投げっぱの時間がありました。ここでビールでも飲んどけってことか! :beers:

3.MySQLの起動・接続

 MySQLを起動します。

mysql.server start

 結果:

Starting MySQL
. SUCCESS! 

 MySQLに接続します。

mysql -uroot

 結果:

Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.7.13 Homebrew

Copyright (c) 2000, 2016, 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> 

 できた。簡単ですね〜。

7
7
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
7
7