My開発メモ

Mysql8のインストールと起動(MacOS/Monterey)

(1) インストール

% brew update
% brew install mysql

確認する

% mysql --version
mysql  Ver 8.0.29 for macos12.2 on arm64 (Homebrew)

(2) 起動とパスワードの設定

以下のサイトにやり方が載っている。

(参考) 【Mac】HomebrewでMySQLをインストールする方法

このやり方で root のパスワードを作成した。

まず、mysql をスタートさせる。

% mysql.server start

以下のコマンドで root のパスワードを設定する

% mysql_secure_installation

mysql_secure_installation

VALIDATE PASSWORD プラグイン
Securing the MySQL server deployment.
Connecting to MySQL using a blank password.
VALIDATE PASSWORD COMPONENT can be used to test passwords
and improve security. It checks the strength of password
and allows the users to set only those passwords which are
secure enough. Would you like to setup VALIDATE PASSWORD component?
Press y|Y for Yes, any other key for No:

VALIDATE PASSWORD コンポーネントをインストールするかどうかを聞いている。

この VALIEDATE PASSWORD というのは、ユーザーのパスワードとして設定できる 文字列に一定の制限をかけるためのプラグインである。

ここでは使用しないことにする。Enter を入力する。(y|Y以外ならよい)

rootユーザーのパスワード
Please set the password for root here.
New password:
Re-enter new password:
anonymous(匿名)ユーザーを削除するか?
By default, a MySQL installation has an anonymous user,
allowing anyone to log into MySQL without having to have
a user account created for them. This is intended only for
testing, and to make the installation go a bit smoother.
You should remove them before moving into a production
environment.
Remove anonymous users? (Press y|Y for Yes, any other key for No) :

「y」でよい。

外部からのrootユーザーでのログインを禁止するか?
Normally, root should only be allowed to connect from
'localhost'. This ensures that someone cannot guess at
the root password from the network.
Disallow root login remotely? (Press y|Y for Yes, any other key for No) :

今回は「y」としたけれど、別の外部PCからrootログインできてもかまわないなあ。

「test」データベースを削除する?
By default, MySQL comes with a database named 'test' that
anyone can access. This is also intended only for testing,
and should be removed before moving into a production
environment.
Remove test database and access to it? (Press y|Y for Yes, any other key for No) :

これも今回は「y」としたけれど、どちらでもいいかな。

確認
Reloading the privilege tables will ensure that all changes
made so far will take effect immediately.
Reload privilege tables now? (Press y|Y for Yes, any other key for No) :

「y」とする。

参考

カテゴリー: MacOS, memo, mysql8

タグ: MacOS, Monterey, mysql8

カウント: 229