LoginSignup
17
16

More than 3 years have passed since last update.

zsh: command not found: mysql が出た際にmysqlのパスを通す方法

Posted at

mysqlコマンドを使用する為に行ったことを備忘録として残させていただきます。

環境

MacOS
mysql5.7

状況

mysqlコマンドでデータベースに接続しようとしたところ、

-> % mysql -u root
zsh: command not found: mysql

と表示されてしまった。

行ったこと

①mysqlがインストールされているかどうかを確認
-> % brew list| grep mysql
mysql@5.7

私の場合はmysql5.7を指定していたので、
任意のバージョンがインストールされていることを確認。

mysqlは入っているので、パスが通っていないのではないかと推測。

②mysqlのパスを通す
echo 'export PATH="/usr/local/opt/mysql@5.7/bin:$PATH"' >> ~/.bash_profile
③反映させる
-> % source ~/.bash_profile

これで無事、

-> % mysql --version
mysql  Ver 14.14 Distrib 5.7.29, for osx10.15 
(x86_64) using  EditLine wrapper

mysqlコマンドを使用することができました!

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