まぬねこの足跡。。。

備忘録+たのしさ+ひっそりと

VPS MariaDBインストール 

環境

ちょこっとメモ

DB:データベース

  • 下記の2パターン
    • データベースアプリケーション自体
    • データ保存の為のテーブル構造

手順

1.MariaDBをインストール

[root@localhost ~]# yum install mariadb-server
   :
Installed size: 110 M
Is this ok [y/d/N]: y ←「y」を入力
   :
Complete!  ←で成功

2.サーバーとMariaDBを同時起動設定

下記を入力

[root@□□-□□□□ ~]# systemctl enable mariadb

3.サービスユニットリストで同時起動確認

下記を入力

[root@□□-□□□□ ~]# systemctl list-unit-files -t service

下記になっていれば成功!! ※)「q」で表示終了

3.MariaDB再起動

下記を入力

[root@□□-□□□□ ~]# systemctl start mariadb

無表示でOK

4.MariaDBログインパスワードを設定

初期設定

インストール
[root@□□-□□□□ ~]# mysql_secure_installation

無表示でOK

ちょこっとメモ

mysql_secure_installationコマンド

  • パスワードの設定・初期設定できる。
  • MariaDBMySQLから派生しているのでMySQLコマンドが使用可

設定
  • パスワードと設定を変更
NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB
      SERVERS IN PRODUCTION USE!  PLEASE READ EACH STEP CAREFULLY!

In order to log into MariaDB to secure it, we'll need the current
password for the root user.  If you've just installed MariaDB, and
you haven't set the root password yet, the password will be blank,
so you should just press enter here.

Enter current password for root (enter for none): ←初期パスワード:Enterキーのみ入力
OK, successfully used password, moving on...

Setting the root password ensures that nobody can log into the MariaDB
root user without the proper authorisation.

Set root password? [Y/n] Y ← rootパスワード再設定の有無:「y」を入力
New password:  ← rootパスワード入力(入力内容非表示)
Re-enter new password:  ← rootパスワード再入力(入力内容非表示)
Password updated successfully!
Reloading privilege tables..
 ... Success!


By default, a MariaDB installation has an anonymous user, allowing anyone
to log into MariaDB 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? [Y/n] Y ←「y」を入力
 ... Success!

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? [Y/n] Y ←「y」を入力
 ... Success!

By default, MariaDB 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? [Y/n] Y ←「y」を入力
 - Dropping test database...
 ... Success!
 - Removing privileges on test database...
 ... Success!

Reloading the privilege tables will ensure that all changes made so far
will take effect immediately.

Reload privilege tables now? [Y/n] Y ←「y」を入力
 ... Success!

Cleaning up...

All done!  If you've completed all of the above steps, your MariaDB
installation should now be secure.

Thanks for using MariaDB!
[root@localhost etc]#

5.MariaDB rootログイン確認

MariaDBへのログイン

Linuxユーザーとしてログイン後、DBユーザーとしてログインすること

[root@localhost etc]# mysql -u root -p
Enter password:
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 10
Server version: 5.5.60-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)]> ←これでOK

6.MariaDB rootログアウト

ログアウト (2パターン)

コマンド入力
MariaDB [(none)]> exit
「Ctl+C」キー入力

MariaDBの構造

下記3つのデータベースが最初から存在する
  • information_schema
  • mysql
  • persormance_schema
確認方法
MariaDB [(none)]> show databases;

すると。。下記が表示される。

+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
+--------------------+
3 rows in set (0.00 sec)