MacへMySQLをHomebrewでインストールする

スポンサーリンク

MacへMySQLをHomebrewでインストールすることについて解説しています。

■PC環境

macOS High Sierra バージョン10.13.6

Homebrew バージョン 2.5.7

■ターミナルを起動する

まずはMacを起動後、「ユーティリティ」から「ターミナル」をダブルクリックで起動します。

$ brew install mysql

起動すると、ターミナルのウインドウが表示されますので、上記のコマンドを入力し、Return/Enterキーを押します。

Return/Enterキーを押すと、Homebrewのアップデートが行われ、Mysqlのインストールが開始されるが、「macOS High Sierra バージョン10.13.6」を使用してため、

Warning: You are using macOS 10.13.
We (and Apple) do not provide support for this old version.
You will encounter build failures with some formulae.
Please create pull requests instead of asking for help on Homebrew’s GitHub,
Twitter or any other official channels. You are responsible for resolving
any issues you experience while you are running this
old version.

上記の警告が表示される。「あなたはmacOS 10.13を使用しています。 この古いバージョンに対するサポートは行っておりません。 いくつかの式でビルドに失敗することがあります。」ということで、現在のmacOSのバージョンがサポートしていないので、バージョンアップする必要がある。

Homebrewのアップデートがかかったことで、他のインストールしたパッケージもアップデートが行われ、時間がかかる。アップデートで途中で「”jar”コマンドラインツールを使用するには、JDKをインストールする必要があります。」というウインドウが表示されるので、「OK」ボタンをクリックする。

==> Installing mysql
==> cmake . -DFORCE_INSOURCE_BUILD=1 -DCOMPILATION_COMMENT=Homebrew -DINSTALL_DO
==> make
==> make install
==> ./mysql-test-run.pl status --vardir=/private/tmp/d20210330-94675-lhc6fx
==> /usr/local/Cellar/mysql/8.0.23_1/bin/mysqld --initialize-insecure --user=use
==> 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/8.0.23_1: 297 files, 295.7MB, built in 25 minutes 19 seconds
==> `brew cleanup` has not been run in 30 days, running now...
Removing: /usr/local/Cellar/gdbm/1.18.1_1... (25 files, 624.9KB)
Removing: /Users/user/Library/Caches/Homebrew/gdbm--1.18.1_1.high_sierra.bottle.tar.gz... (204.0KB)
Removing: /Users/user/Library/Caches/Homebrew/gh--1.1.0.high_sierra.bottle.tar.gz... (5.7MB)
Removing: /usr/local/Cellar/openssl@1.1/1.1.1g... (8,059 files, 18.4MB)
Removing: /usr/local/Cellar/readline/8.0.4... (48 files, 1.5MB)
Removing: /Users/user/Library/Caches/Homebrew/readline--8.0.4.high_sierra.bottle.tar.gz... (517.6KB)
Removing: /usr/local/Cellar/sqlite/3.32.3... (11 files, 4MB)
Removing: /Users/user/Library/Caches/Homebrew/xz--5.2.5.high_sierra.bottle.tar.gz... (386.6KB)
Removing: /Users/user/Library/Caches/Homebrew/portable-ruby-2.6.3_2.yosemite.bottle.tar.gz... (9.1MB)
Removing: /Users/user/Library/Logs/Homebrew/gh... (68B)
Pruned 1 symbolic links and 2 directories from /usr/local

しばらくしてようやくMysqlのインストールが開始される。

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

開始してしばらくすると、上記のメッセージが表示される。これでMysqlのインストールは完了となる。

$ brew info mysql

完了後、上記のコマンドを入力し、Return/Enterキーを押します。これでMysqlの情報を確認する。

mysql: stable 8.0.23
Open source relational database management system

https://dev.mysql.com/doc/refman/8.0/en/
Conflicts with: mariadb (because mysql, mariadb, and percona install the same binaries) percona-server (because mysql, mariadb, and percona install the same binaries) /usr/local/Cellar/mysql/8.0.23_1 (297 files, 295.7MB) * Built from source on 2021-03-30 at 15:21:46 From: https://github.com/Homebrew/homebrew-core/blob/HEAD/Formula/mysql.rb License: GPL-2.0-only ==> Dependencies Build: cmake ✔ Required: openssl@1.1 ✔, protobuf ✔ ==> 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 ==> Analytics install: 92,870 (30 days), 241,201 (90 days), 875,756 (365 days) install-on-request: 91,858 (30 days), 238,426 (90 days), 856,256 (365 days) build-error: 0 (30 days)

確認すると、Mysqlのバージョン8.0.23がインストールされたことが確認できた。

コメント

タイトルとURLをコピーしました