Mac ローカルにインストールした MySQL を使う方法

  1. MySQL を起動する
  2. MySQL に接続する
  3. MySQL を遮断する
  4. MySQL を終了する

1. MySQL を起動する

コマンド「brew services start mysql」でローカルの MySQL を起動します。

% brew services start mysql
==> Successfully started `mysql` (label: homebrew.mxcl.mysql)

2. MySQL に接続する

コマンド「mysql -u root」で MySQL に接続します。

% mysql -u root
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 9
Server version: 8.0.23 Homebrew

Copyright (c) 2000, 2021, Oracle and/or its affiliates.

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>

3. MySQL を遮断する

コマンド「exit」で MySQL のコマンドプロンプトから出ます。

mysql> exit
Bye

4. MySQL を終了する

コマンド「brew services stop mysql」で終了です。

% brew services stop mysql
==> Successfully stopped `mysql` (label: homebrew.mxcl.mysql)

コメントを残す

メールアドレスが公開されることはありません。 * が付いている欄は必須項目です