SlideShare uses cookies to improve functionality and performance, and to provide you with relevant advertising. If you continue browsing the site, you agree to the use of cookies on this website. See our User Agreement and Privacy Policy.
SlideShare uses cookies to improve functionality and performance, and to provide you with relevant advertising. If you continue browsing the site, you agree to the use of cookies on this website. See our Privacy Policy and User Agreement for details.
Successfully reported this slideshow.
Activate your 30 day free trial to unlock unlimited reading.
3.
DBサーバーの初期設定(1)
MariaDBのインストール確認
--version
MariaDBの起動
systemctl start
MariaDBの起動確認
Systemctl status
自動起動設定もあわせて設定します。
Systemctl enable
3
手順6 [root@suzukto ~]# systemctl␣start␣mariadb
● mariadb.service - MariaDB 10.3 database server
Loaded: loaded (/usr/lib/systemd/system/mariadb.service; disabled; vendor preset: disabled)
Active: active (running) since Wed 2020-12-30 05:50:28 JST; 2s ago
Docs: man:mysqld(8)
手順5 [root@suzukto ~]# mysql␣--version
mysql Ver 15.1 Distrib 10.3.17-MariaDB, for Linux (x86_64) using readline 5.1
手順8 [root@suzukto ~]# systemctl␣enable␣mariadb
Created symlink /etc/systemd/system/mysql.service → /usr/lib/systemd/system/mariadb.service.
Created symlink /etc/systemd/system/mysqld.service → /usr/lib/systemd/system/mariadb.service.
Created symlink /etc/systemd/system/multi-user.target.wants/mariadb.service →
/usr/lib/systemd/system/mariadb.service.
手順7 [root@suzukto ~]# systemctl␣status␣mariadb
4.
DBサーバーの初期設定(2)
MariaDBの自動起動確認
--version
4
手順9 [root@suzukto ~]# systemctl␣status␣mariadb
● mariadb.service - MariaDB 10.3 database server
Loaded: loaded (/usr/lib/systemd/system/mariadb.service; enabled; vendor preset: disabled)
Active: active (running) since Wed 2020-12-30 05:50:28 JST; 15min ago
Docs: man:mysqld(8)
5.
DBサーバーの初期設定(3)
MariaDBの初期化
環境によって設定の差異が出ないように初期化します。
mysql_secure_installation
Enter current password for root (enter for none):
Enterを押します。rootの初期パスワードは空です。
Set root password? [Y/n]
「y」で応答し、rootユーザーのパスワードを設定します。
Remove anonymous users? [Y/n]
「y」で応答し、匿名ユーザーを削除します。
5
手順10 [root@suzukto ~]#mysql_secure_installation
Set root password? [Y/n] Y
New password: ←P@ssw0rdを入力します。(表示はされません)
Re-enter new password: ←確認のためもう一度入力します。
Password updated successfully! ←成功しました。
Reloading privilege tables..
... Success!
... Success!
Set root password? [Y/n] Y
Remove anonymous users? [Y/n] Y
Enter current password for root (enter for none):
6.
DBサーバーの初期設定(4)
Disallow root login remotely? [Y/n]
「y」で応答し、rootユーザーのリモートログインを無効化します。
Remove test database and access to it? [Y/n]
「y」で応答し、デフォルトで作成されているテストデータベースを削除します。
Reload privilege tables now? [Y/n]
「y」で応答し、権限テーブルを再読み込みします
「Cleaning up...」と表示されたら初期化成功です。
6
Disallow root login remotely? [Y/n] Y
... Success!
Remove test database and access to it? [Y/n] Y
Reload privilege tables now? [Y/n] Y
- Dropping test database...
... Success!
- Removing privileges on test database...
... Success!
... Success!
7.
DBサーバーへの接続とDB/ユーザー作成(1)
MariaDBへ接続
mysql mysql #mysql –u root –p
プロンプトが変化していればログイン成功です。
7
手順11[root@suzukto ~]#mysql□-u␣root␣-p
Enter password: ←パスワードを入力します。
Welcome to the MariaDB monitor. Commands end with ; or ¥g.
Your MariaDB connection id is 21
Server version: 10.3.17-MariaDB MariaDB Server
Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '¥h' for help. Type '¥c' to clear the current input statement.
MariaDB [(none)]>
8.
DBサーバーへの接続とDB/ユーザー作成(2)
データベース作成
データ入力などで使用するためのデータベースを作成します
create database webdb default character set = utf8;
データベースが追加されているか確認します
show database;
8
手順12 MariaDB [(none)]> create␣database␣webdb␣default␣character␣set␣=␣utf8;
Query OK, 1 row affected (0.001 sec)
MariaDB [(none)]> create database webdb default character set = utf8
->
(セミコロン忘れ)
手順13 MariaDB [(none)]> show␣databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| webdb |
+--------------------+
4 rows in set (0.001 sec)
9.
DBサーバーへの接続とDB/ユーザー作成(3)
ユーザーの作成
データ入力などで使用するためのユーザー/パスワードを作成します
create user webuser@’%’ identified by ‘{パスワード}’
先ほど作成したデータベースに対して全ての権限を与えます
grant all on webdb.* to webuser@’%’;
権限が付与されているか確認します
show grants for webuser@’%’;
9
手順14 MariaDB [(none)]> create␣user␣webuser@’%'␣identified␣by␣'P@ssw0rd';
Query OK, 1 row affected (0.001 sec)
手順15 MariaDB [(none)]> grant␣all␣on␣webdb.*␣to␣webuser@’%';
Query OK, 1 row affected (0.001 sec)
手順16 MariaDB [(none)]> show␣grants␣for␣webuser@’%';
+--------------------------------------------------------------------------------------------------------+
| Grants for webuser@% |
+--------------------------------------------------------------------------------------------------------+
| GRANT USAGE ON *.* TO 'webuser'@'%' IDENTIFIED BY PASSWORD '*8232A1298A49F710DBEE0B330C42EEC825D4190A' |
| GRANT ALL PRIVILEGES ON `webdb`.* TO 'webuser'@'%' |
+--------------------------------------------------------------------------------------------------------+
2 rows in set (0.000 sec)
もし権限がなかったら
flush privileges;