0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

Homebrewを使ったMySQLのインストール・起動・停止・初期設定・アンインストール

Posted at

概要

Homebrewを使ってMySQLサーバをmacOSにインストール・アンインストールする手順を示す

MySQLのインストール〜起動

HomebrewでMySQLをインストールするコマンドは以下

$ brew install mysql

インストール後、MySQLのサービスを起動する

$ brew services start mysql

MySQLのサービスが起動しrootユーザでのログインが可能になる

$ mysql -u root

MySQLの初期セキュリティ設定(mysql_secure_installation)

MySQLの初期セキュリティ設定を行う対話コマンドを実行する
以下のコマンドを入力

$ # HomebrewでのMySQLサービス起動
$ brew services start mysql
$ # 初期セキュリティ設定起動
$ mysql_secure_installation

実行後の質問①-1「Would you like to setup VALIDATE PASSWORD component?」

パスワード強度チェックを使うかどうか

実行後の質問①-2「パスワードの強度のレベル設定」

①-1で「Y」を入力すると続けて「パスワードの強度のレベル設定」を決める

$ There are three levels of password validation policy:
$ LOW    Length >= 8
$ MEDIUM Length >= 8, numeric, mixed case, and special characters
$ STRONG Length >= 8, numeric, mixed case, special characters and dictionary check
% Please enter 0 = LOW, 1 = MEDIUM and 2 = STRONG:

パスワードの強度チェックのレベルを設定する

LOW:0
長さ8文字以上

MEDIUM:1
長さ8文字以上/数字・英大小文字・記号を使用

STORONG:2
長さ8文字以上/数字・英大小文字・記号を使用/非推奨語チェック

実行後の質問②「New password:」

rootユーザのパスワード

実行後の質問③「Re-enter new password:」

②の再確認

実行後の質問④「Remove anonymous users?」

匿名ユーザを削除するか

実行後の質問⑤「Disallow root login remotely?」

rootユーザでリモート接続を禁止するか

実行後の質問⑥「Remove test database and access to it?」

テスト用のDBを削除するか

実行後の質問⑦「Reload privilege tables now?」

権限テーブルを再読み込みするか

MySQLのアンインストール

$ # MySQLの停止
$ brew services stop mysql
$ # MySQLのアンインストール
$ brew uninstall mysql
$ # MySQLのデータディレクトリをsudoで削除(sudoをつけないと一部ファイルが削除されないことがあるため
$ sudo rm -rf /opt/homebrew/var/mysql
$ # 設定キャッシュなどを一応掃除(ファイル自体存在しない可能性もあり)
$ rm -rf ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist
$ rm -rf /usr/local/etc/my.cnf
0
0
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
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?