0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

MacにMySQLを入れたときに起こったイベント

Last updated at Posted at 2018-05-18

手元にある古い MacBookAir に開発環境を用意したい。まず DB として MySQL を使おうと思って設定しようとしたときの顛末をメモ。

#環境

$ sw_vers
ProductName:	Mac OS X
ProductVersion:	10.12.6
BuildVersion:	16G29

#作業手順

$ which mysql
$

MySQLが入ってない。brew ってので入れるらしい。

$ which brew
/usr/local/bin/brew
$ brew install mysql
Error: Could not create /usr/local/Cellar
Check you have permission to write to /usr/local

利用アカウントでは /usr/local にパーミッションがない、らしい。
root で実行するために sudo を使ってみる。

$ sudo brew install mysql
Password:
Error: Cowardly refusing to `sudo brew install`
You can use brew with sudo, but only if the brew executable is owned by root.
However, this is both not recommended and completely unsupported so do so at
your own risk.

root でインストールするとか危ないやんかと諭される。

わかんないのでググる。以下を参考にする。

brew doctor をするといいらしい。

$ brew doctor
Please note that these warnings are just used to help the Homebrew maintainers
with debugging if you file an issue. If everything you use Homebrew for is
working fine: please don't worry and just ignore them. Thanks!

Warning: The /usr/local directory is not writable.
Even if this directory was writable when you installed Homebrew, other
software may change permissions on this directory. Some versions of the
"InstantOn" component of Airfoil are known to do this.

You should probably change the ownership and permissions of /usr/local
back to your user account.

Warning: Your Homebrew is outdated.
You haven't updated for at least 24 hours. This is a long time in brewland!
To update Homebrew, run `brew update`.

他のソフトがパーミッション変えたみたいよ、とか Homebrew が古いよはよ update しろや、と詰られる。

素直に update する。

$ brew update
warning: unable to unlink .yardopts: Permission denied
warning: unable to unlink CONTRIBUTING.md: Permission denied
warning: unable to unlink SUPPORTERS.md: Permission denied
fatal: cannot create directory at '.github': Permission denied
Error: Failure while executing: git pull -q origin refs/heads/master:refs/remotes/origin/master

あ?とりあえず git pull できんよ、と。

わかんないのでググる(2回目)。以下を参考にする。

git のデータが汚れている?らしいので強制的にきれいにします。

$ git reset --hard && git clean -df
HEAD is now at 8f69a54 Mention homebrew-go-resources in cookbook

で、再び brew update する。

$ brew update
Error: /usr/local is not writable. You should change the
ownership and permissions of /usr/local back to your
user account:
  sudo chown -R $(whoami) /usr/local

メッセージが変わった。対象dir のオーナーを変更しろとおっしゃる。

$ whoami
hoge
$ sudo chown -R hoge /usr/local
$ brew update
Already up-to-date.

ふう。ようやく brew の設定が終わった。MySQL を入れる。

brew install mysql
==> Downloading https://homebrew.bintray.com/bottles-portable-ruby/portable-ruby-2.3.3_2.leopard_64.bottle.tar.gz
######################################################################## 100.0%
==> Pouring portable-ruby-2.3.3_2.leopard_64.bottle.tar.gz
==> Tapping homebrew/core
Cloning into '/usr/local/Library/Taps/homebrew/homebrew-core'...
remote: Counting objects: 4755, done.
remote: Compressing objects: 100% (4551/4551), done.
remote: Total 4755 (delta 55), reused 619 (delta 17), pack-reused 0
Receiving objects: 100% (4755/4755), 3.85 MiB | 264.00 KiB/s, done.
Resolving deltas: 100% (55/55), done.
Checking connectivity... done.
Tapped 4544 formulae (4,795 files, 12MB)
Error: Your Xcode (6.4) is too outdated.
Please update to Xcode 9.2 (or delete it).
Xcode can be updated from the App Store.

Error: Xcode alone is not sufficient on Sierra.
Install the Command Line Tools:
  xcode-select --install

は? Xcode ってのが古いってか。

$ xcode-select --install
xcode-select: note: install requested for command line developer tools

と叩くとインストールが始まる。

$ brew install mysql
Updating Homebrew...
==> Homebrew has enabled anonymous aggregate user behaviour analytics.
Read the analytics documentation (and how to opt-out) here:
  https://docs.brew.sh/Analytics

==> Auto-updated Homebrew!
Updated 1 tap (homebrew/core).
==> Updated Formulae
armadillo                                                              fn

==> Migrating HOMEBREW_REPOSITORY (please wait)...
==> Migrated HOMEBREW_REPOSITORY to /usr/local/Homebrew!
Homebrew no longer needs to have ownership of /usr/local. If you wish you can
return /usr/local to its default ownership with:
  sudo chown root:wheel /usr/local
Error: Your Xcode (6.4) is too outdated.
Please update to Xcode 9.2 (or delete it).
Xcode can be updated from the App Store.

うーん、App Store から入れないとだめなのか。めっちゃ時間かかるやん。。

1日かけて Xcode をインストール後。

$ brew install mysql
Error: You have not agreed to the Xcode license. Please resolve this by running:
  sudo xcodebuild -license accept

ライセンスか。

$ sudo xcodebuild -license accept
Password:

で再び。

brew install mysql
==> Downloading https://homebrew.bintray.com/bottles-portable-ruby/portable-ruby-2.3.3_2.leopard_64.bottle.tar.gz
Already downloaded: /Users/hoge/Library/Caches/Homebrew/portable-ruby-2.3.3_2.leopard_64.bottle.tar.gz
==> Pouring portable-ruby-2.3.3_2.leopard_64.bottle.tar.gz
Updating Homebrew...
==> Auto-updated Homebrew!
Updated 1 tap (homebrew/core).
==> New Formulae
wireguard-go
==> Updated Formulae
aria2            dbxml            gauge            jhiccup          maxwell          node-build       poppler          spring-roo
aws-sdk-cpp      debianutils      git-ftp          libqalculate     mercurial        node@8           pound            wireguard-tools
cake             faas-cli         grpc             libu2f-host      mpc              pam-u2f          proguard         xqilla
citus            fdroidserver     gtksourceview@4  lxc              nano             pilosa           sops             you-get

==> Installing dependencies for mysql: openssl
==> Installing mysql dependency: openssl
==> Downloading https://homebrew.bintray.com/bottles/openssl-1.0.2o_1.sierra.bottle.tar.gz
######################################################################## 100.0%
==> Pouring openssl-1.0.2o_1.sierra.bottle.tar.gz
==> Caveats
A CA file has been bootstrapped using certificates from the SystemRoots
keychain. To add additional certificates (e.g. the certificates added in
the System keychain), 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,
because Apple has deprecated use of OpenSSL in favor of its own TLS and crypto libraries.

If you need to have this software first in your PATH run:
  echo 'export PATH="/usr/local/opt/openssl/bin:$PATH"' >> ~/.bash_profile

For compilers to find this software you may need to set:
    LDFLAGS:  -L/usr/local/opt/openssl/lib
    CPPFLAGS: -I/usr/local/opt/openssl/include

==> Summary
🍺  /usr/local/Cellar/openssl/1.0.2o_1: 1,791 files, 12.3MB
==> Installing mysql
==> Downloading https://homebrew.bintray.com/bottles/mysql-5.7.22.sierra.bottle.tar.gz
####################################################################      94.7%"
######################################################################## 100.0%
==> Pouring mysql-5.7.22.sierra.bottle.tar.gz
==> /usr/local/Cellar/mysql/5.7.22/bin/mysqld --initialize-insecure --user=hoge --basedir=/usr/local/Cellar/mysql/5.7.22 --datadir=/usr
==> Caveats
We've installed your MySQL database without a root password. To secure it run:
    mysql_secure_installation

MySQL is configured to only allow connections from localhost by default

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.22: 317 files, 233.9MB

これで入った、のか?(不安)

$ which mysql
/usr/local/bin/mysql
$ mysql --version
mysql  Ver 14.14 Distrib 5.7.22, for osx10.12 (x86_64) using  EditLine wrapper

入ったみたい。

感想

意外と引っかかったけれど、ググルとどうにでもなるのでインターネット環境って凄いなと思いました。

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?