質問をすることでしか得られない、回答やアドバイスがある。

15分調べてもわからないことは、質問しよう!

新規登録して質問してみよう
ただいま回答率
85.48%
MySQL

MySQL(マイエスキューエル)は、TCX DataKonsultAB社などが開発するRDBMS(リレーショナルデータベースの管理システム)です。世界で最も人気の高いシステムで、オープンソースで開発されています。MySQLデータベースサーバは、高速性と信頼性があり、Linux、UNIX、Windowsなどの複数のプラットフォームで動作することができます。

Q&A

解決済

1回答

7268閲覧

HomebrewでMysqlをインストールできない

ogw

総合スコア8

MySQL

MySQL(マイエスキューエル)は、TCX DataKonsultAB社などが開発するRDBMS(リレーショナルデータベースの管理システム)です。世界で最も人気の高いシステムで、オープンソースで開発されています。MySQLデータベースサーバは、高速性と信頼性があり、Linux、UNIX、Windowsなどの複数のプラットフォームで動作することができます。

0グッド

0クリップ

投稿2018/08/29 15:00

解決したい事

  • Mysql5.7を利用したい
  • インストールしてもcommand not foundになってしまう。
$ mysql --version -bash: mysql: command not found

環境

Mac OX 10.11.4(El Captain)

試した事

$ brew reinstall mysql@5.7 ==> Reinstalling mysql@5.7 ==> Downloading https://homebrew.bintray.com/bottles/mysql@5.7-5.7.23.el_capitan Already downloaded: /Users/oogw/Library/Caches/Homebrew/mysql@5.7--5.7.23.el_capitan.bottle.tar.gz ==> Pouring mysql@5.7--5.7.23.el_capitan.bottle.tar.gz ==> 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 mysql@5.7 is keg-only, which means it was not symlinked into /usr/local, because this is an alternate version of another formula. If you need to have mysql@5.7 first in your PATH run: echo 'export PATH="/usr/local/opt/mysql@5.7/bin:$PATH"' >> ~/.bash_profile For compilers to find mysql@5.7 you may need to set: export LDFLAGS="-L/usr/local/opt/mysql@5.7/lib" export CPPFLAGS="-I/usr/local/opt/mysql@5.7/include" For pkg-config to find mysql@5.7 you may need to set: export PKG_CONFIG_PATH="/usr/local/opt/mysql@5.7/lib/pkgconfig" To have launchd start mysql@5.7 now and restart at login: brew services start mysql@5.7 Or, if you don't want/need a background service you can just run: /usr/local/opt/mysql@5.7/bin/mysql.server start ==> Summary ???? /usr/local/Cellar/mysql@5.7/5.7.23: 317 files, 235.2MB
$ ls /usr/local/bin/ VBoxAutostart gvpack VBoxBalloonCtrl gvpr VBoxBugReport gxl2dot VBoxDTrace gxl2gv VBoxHeadless heroku VBoxManage ifnames VBoxVRDP img2webp VirtualBox initdb acyclic jpegtran annotate libpng-config apm libpng16-config atom meteor autoconf mm2gv autoheader neato autom4te node autoreconf nop autoscan npm autoupdate npx bcomps oid2name bdftogd osage brew pal2rgb c++-8 patchwork ccmake pg_archivecleanup ccomps pg_basebackup chromedriver pg_config circo pg_controldata cjpeg pg_ctl cluster pg_dump clusterdb pg_dumpall cmake pg_isready cmakexbuild pg_receivewal cpack pg_recvlogical cpp-8 pg_resetwal createdb pg_restore createuser pg_rewind ctest pg_standby cwebp pg_test_fsync diffimg pg_test_timing dijkstra pg_upgrade djpeg pg_waldump dot pgbench dot2gxl pkg-config dot_builtins png-fix-itxt dropdb pngfix dropuser pngtogd dwebp pngtogd2 ecpg postgres edgepaint postmaster fax2ps ppm2tiff fax2tiff prune fc-cache psql fc-cat raw2tiff fc-conflist rbenv fc-list rbenv-communal-gem-home fc-match rbenv-communize fc-pattern rbenv-install fc-query rbenv-sequester fc-scan rbenv-uninstall fc-validate rdjpgcom fdp reindexdb freetype-config ruby-build g++-8 sccmap gc selenium-server gcc-8 sfdp gcc-ar-8 tiff2bw gcc-nm-8 tiff2pdf gcc-ranlib-8 tiff2ps gcov-8 tiff2rgba gcov-dump-8 tiffcmp gcov-tool-8 tiffcp gd2copypal tiffcrop gd2togif tiffdither gd2topng tiffdump gdcmpgif tiffinfo gdlib-config tiffmedian gdparttopng tiffset gdtopng tiffsplit gfortran tred gfortran-8 twopi gibo unflatten giftogd2 vacuumdb git vacuumlo git-cvsserver vagrant git-receive-pack vbox-img git-shell vboxwebsrv git-upload-archive webpinfo git-upload-pack webpmux gitk webpng glibtool wrjpgcom glibtoolize x86_64-apple-darwin15.6.0-c++-8 gml2gv x86_64-apple-darwin15.6.0-g++-8 graphml2gv x86_64-apple-darwin15.6.0-gcc-8 gv2gml x86_64-apple-darwin15.6.0-gcc-8.2.0 gv2gxl x86_64-apple-darwin15.6.0-gcc-ar-8 gvcolor x86_64-apple-darwin15.6.0-gcc-nm-8 gvgen x86_64-apple-darwin15.6.0-gcc-ranlib-8 gvmap x86_64-apple-darwin15.6.0-gfortran-8
$ brew info mysql mysql: stable 8.0.12 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.) mariadb-connector-c (because both install plugins) mysql-cluster (because mysql, mariadb, and percona install the same binaries.) mysql-connector-c (because both install MySQL client libraries) percona-server (because mysql, mariadb, and percona install the same binaries.) Not installed From: https://github.com/Homebrew/homebrew-core/blob/master/Formula/mysql.rb ==> Dependencies Build: cmake ✔ Required: openssl ✔ ==> Requirements Required: macOS >= 10.10 ✔ ==> Options --with-debug Build with debug support --with-embedded Build the embedded server --with-local-infile Build with local infile loading support --with-memcached Build with InnoDB Memcached plugin --with-test Build with unit tests ==> 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 MBP:$ brew link mysql Error: No such keg: /usr/local/Cellar/mysql
$ brew list autoconf heroku mysql@5.7 chromedriver heroku-node node cmake icu4c openssl fontconfig isl pkg-config freetype jpeg postgresql gcc libmpc rbenv gd libpng rbenv-communal-gems gibo libtiff readline git libtool ruby-build gmp mpfr selenium-server-standalone graphviz mysql webp

気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

guest

回答1

0

ベストアンサー

brew doctorと打つとどうなりますでしょうか?
エラーなど出てないでしょうか?エラーがある場合修復するコマンドを教えてくれます。
自分の場合は大抵これで直ります。

brew listmysql(8.0.12?)とmysql@5.7があるのも気になりますね。

投稿2018/08/29 23:38

taka2063

総合スコア307

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

ogw

2018/08/30 00:55 編集

回答ありがとうございます。 Xcodeのエラー以外は出てない状況です。 ``` $ 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 or file an issue; just ignore this. Thanks! Warning: Your Xcode (7.3.1) is outdated. Please update to Xcode 8.2.1 (or delete it). Xcode can be updated from the App Store. ``` 確かにこちらも気になります。 以前、直接(brewコマンドを使用せずに)入れてしまった記憶があります。 ``` mysql: stable 8.0.12 ```
taka2063

2018/08/30 00:59

Xcodeは入れたほうがいいですね。 Homebrewはコンパイルしないで入れるものとコンパイルしていれるものがあるのでコンパイルするときに必要になりますバージョンが古いと言われているのでものによってはライブラリが古いとかないとかになる可能性があります。 一度、mysqlとmysql@5.7を削除して再度mysql@5.7を入れてはどうでしょう?
ogw

2018/08/30 02:51 編集

ありがとうございます!Xcodeをアップデートして解決しました。 mysql: stable 8.0.12になっている事が不可解です。 ``` $ brew reinstall mysql@5.7 ・ ・ ・ ==> Summary ???? /usr/local/Cellar/mysql@5.7/5.7.23: 317 files, 235.2MB ``` パスを通す ``` $ echo 'export PATH="/usr/local/opt/mysql@5.7/bin:$PATH"' >> ~/.bash_profile $ source ~/.bash_profile ``` 起動成功 ``` $ mysql.server start Starting MySQL . SUCCESS! ``` バージョンを調べる ``` $ mysql --version mysql Ver 14.14 Distrib 5.7.23, for osx10.11 (x86_64) using EditLine wrapper ``` mysql: stable 8.0.12 という表記は変わらず。 ``` $ brew info mysql mysql: stable 8.0.12 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.) mariadb-connector-c (because both install plugins) mysql-cluster (because mysql, mariadb, and percona install the same binaries.) mysql-connector-c (because both install MySQL client libraries) percona-server (because mysql, mariadb, and percona install the same binaries.) Not installed From: https://github.com/Homebrew/homebrew-core/blob/master/Formula/mysql.rb ==> Dependencies Build: cmake ✔ Required: openssl ✔ ==> Requirements Required: macOS >= 10.10 ✔, macOS >= 10.12 ✘ ==> Options --with-debug Build with debug support --with-embedded Build the embedded server --with-local-infile Build with local infile loading support --with-memcached Build with InnoDB Memcached plugin --with-test Build with unit tests ==> 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 ``` Homebrewにはmysql: 8.0.12 がない。 ``` $ cd /usr/local/Cellar/ $ ls mysql mysql@5.7 ```
taka2063

2018/08/30 03:05 編集

やっぱり、mysqlとmysql@5.7がインストールされていてmysql(8.0.12)が動いているようです。 mysq@5.7 --version と入力すると5.7が返ってきます? brew doctorはもう何もエラーないです?
ogw

2018/08/30 04:58 編集

色々とありがとうございます。5.7が返ってきました。 doctorからは問題ないと返ってきました。 $ mysql --version mysql Ver 14.14 Distrib 5.7.23, for osx10.11 (x86_64) using EditLine wrapper $ brew doctor Your system is ready to brew. >必要ないならuninstallしてみては? リンク先の情報に習ってためしたのですが、エラーが返ってきました。 $ brew uninstall mysql Error: No such keg: /usr/local/Cellar/mysql $ cd /usr/local/Cellar/mysql/ $ ls 何も表示されない $ which mysql /usr/local/opt/mysql@5.7/bin/mysql $ cd /usr/local/opt/ $ ls mysql@5.7 ← mysqlと名称があるのはこれのみ 色々調べてみたのですが、下記の解釈としては、バージョン指定しないでインストールした場合、mysql 8.0.12がインストールされますよ。という解釈で問題ないでしょうか。 mysql: stable 8.0.12 $ brew list | grep mysql mysql mysql@5.7 そうだとしたら、5.7がインストールできているので問題ないかなと思っています。 $ mysql --version mysql Ver 14.14 Distrib 5.7.23, for osx10.11 (x86_64) using EditLine wrapper $ mysql -u root -p Enter password: Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 6 Server version: 5.7.23 Homebrew Copyright (c) 2000, 2018, 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> SHOW DATABASES; +--------------------+ | Database | +--------------------+ | information_schema | | mysql | | performance_schema | | sys | +--------------------+ 4 rows in set (0.03 sec)
taka2063

2018/08/30 05:53

あ、ちゃんと動いているのですね。サーバーは5.7でバージョンが表示されていますね。 良かったです。(ちょっとmysql v8だけが釈然としないですねw) クライアントのバージョンがサーバーと違うだけ?うーん
taka2063

2018/08/30 05:56

> 色々調べてみたのですが、下記の解釈としては、バージョン指定しないでインストールした場合、mysql 8.0.12がインストールされますよ。という解釈で問題ないでしょうか。 そういうことかもしれませんね。 > Distrib 5.7.23 クライアントも5.7.23になってるからいいのか
ogw

2018/08/30 06:35

ご丁寧に回答頂きありがとうございました! 初学者の自分にとって今回の件を通して学びが多かったです。
guest

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.48%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問