情報調べる系コマンド極めたい。
普段dockerからmysqlを使っておりましたが、ローカルからmysqlを使いたい事情があり接続を試みました。
しかし以下のように接続に失敗しました。
$ mysql -uroot
fish: Unknown command mysql
理由を調べるため、brew info mysqlコマンドで調べてみたところ、mysqlが入ってはいるもののきちんとmysqlを使うよう指定できていないようでした。
mysql: stable 8.0.18 (bottled)
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-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@1.1 ✔
==> Requirements
Required: macOS >= 10.10 ✔
==> 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:Or, if you don't want/need a background service you can just run:
mysql.server start
==> Analytics
install: 62,540 (30 days), 206,034 (90 days), 801,623 (365 days)
install_on_request: 59,292 (30 days), 192,704 (90 days), 747,576 (365 days)
build_error: 0 (30 days)
mysql5.6がつかいたかったので、5.6を使えるように指定してあげます。
brew link <パッケージ名> でそのパッケージを有効にしてくれます。
Linking /usr/local/Cellar/mysql@5.6/5.6.46... 99 symlinks created
If you need to have this software first in your PATH instead consider running:echo 'set -g fish_user_paths "/usr/local/opt/mysql@5.6/bin" $fish_user_paths' >> ~/.config/fish/config.fish
これで無事mysqlサーバへ接続できるようになりました!!
$ mysql -uroot
Welcome to the MySQL monitor. Commands end with ; or g.
Your MySQL connection id is 1
Server version: 5.6.43 Homebrew
Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or itsaffiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or 'h' for help. Type 'c' to clear the current input statement.
感想その他
情報を調べる系コマンドをたくさん知っておくと、エラー解決捗るようになる気がしました。極めたい。