CentOs8 Mysql 8をインストールする

centos8にmysql8をインストールする手順です。「dnf」を使用してインストールしてます。ここでは初期設定までを記述してます。
環境
OS CentOS Linux release 8.0.1905 (Core)
Mysql8インストール
mysql8をインストールするまえにバージョンを確認します。
$ dnf info mysql
<出力結果>
名前 : mysql
バージョン : 8.0.17
8.0.17となっているので、このままインストールします。
## インストール
$ sudo dnf install @mysql:8.0
バージョンを確認します
$ mysql --version
<出力結果>
mysql Ver 8.0.17 for Linux on x86_64 (Source distribution)
自動起動の設定と起動します。
## 自動起動
$ systemctl enable mysqld
## 起動
$ systemctl start mysqld
## 再起動
$ systemctl restart mysqld
初期設定を行います
## 初期設定
$ mysql_secure_installation
<出力結果>
## パスワード設定
Press y|Y for Yes, any other key for No: y
## パスワードのポリシー設定 2を選択
Please enter 0 = LOW, 1 = MEDIUM and 2 = STRONG: 2
## rootのパスワードの設定
New password:
Re-enter new password:
## 設定したパスワードで問題なければ y
Do you wish to continue with the password provided?(Press y|Y for Yes, any other key for No) : y
## 匿名ユーザーはいらないので y
Remove anonymous users? (Press y|Y for Yes, any other key for No) : y
## rootでのリモート接続はさせないので y
Disallow root login remotely? (Press y|Y for Yes, any other key for No) : y
## テストDBは不要なので y
Remove test database and access to it? (Press y|Y for Yes, any other key for No) : y
## 設定を反映させるので y
Reload privilege tables now? (Press y|Y for Yes, any other key for No) : y
さきほど作成したパスワードで接続してみます。
$ mysql -u root -p
Enter password さきほど設定したパスワードを入力
ログインできれば設定が反映されています。
簡単なSQL
DBやユーザーの作成は、以下のコマンドで可能です。
# DBの作成
mysql> create database DB名;
# ユーザーの作成
mysql> create user 'ユーザー名'@'localhost' identified with mysql_native_password by 'つけたいパスワード';
# ユーザーに権限を付与
mysql> grant all on `データベース名`.* to 'ユーザー名'@'localhost' with grant option;
-
前の記事
Vue.js breadstickを使用してをNotificationを表示するまでの手順 2020.02.07
-
次の記事
Vue.js vue-yandex-shareを使用してsnsシェアボタンを実装する 2020.02.07
コメントを書く