Help us understand the problem. What is going on with this article?

Macのhomebrewでmysqlクライアントのみインストールする

Macのローカルに作った開発環境のmysqlに接続はしたいけどサーバーはインストールしたくなかったのでメモ

homebrewの確認

homebrewはインストール済みであることが前提です

$ brew -v
Homebrew 2.2.2
Homebrew/homebrew-core (git revision fdb53; last commit 2020-01-03)
Homebrew/homebrew-cask (git revision d9c8; last commit 2020-01-03)

mysql確認

$ mysql --version
-bash: mysql: command not found

入ってません。

インストール

brew install mysql --client-only
...
Error: invalid option: --client-only

あれ、エラーになってしまうようですね。どうやらこのコマンドだと私の環境ではインストールできないようです。

以下のコマンドでインストール出来ました。

brew install mysql-client

インストールできました。

...
######################################################################## 100.0%
==> Pouring mysql-client-8.0.18.high_sierra.bottle.tar.gz
==> Caveats
mysql-client is keg-only, which means it was not symlinked into /usr/local,
because it conflicts with mysql (which contains client libraries).

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

For compilers to find mysql-client you may need to set:
  export LDFLAGS="-L/usr/local/opt/mysql-client/lib"
  export CPPFLAGS="-I/usr/local/opt/mysql-client/include"

パスを通す

ログにもありますが、パスを通さないと、「mysql」コマンドで呼び出せないようです。

$ mysql --version
-bash: mysql: command not found

以下のように.bash_profileに書き込んで、sourceコマンドで即時反映させればOKです。

$ echo 'export PATH="/usr/local/opt/mysql-client/bin:$PATH"' >> ~/.bash_profile
$ source ~/.bash_profile

確認

$ mysql --version
mysql  Ver 8.0.18 for osx10.13 on x86_64 (Homebrew)

おつかれさまでした。

Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
No comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
ユーザーは見つかりませんでした