1 views
実現する機能
データベースサーバーは、サーバー上のデータベースをクライアントから操作できるようにするためのサーバー。WordPressもデータベースを使う必要があるので、ここでは、リレーショナル型データベースのデータベースサーバーであるMariaDBの導入手順を紹介します。MySQLがどうなるのかは気になるところですが、とりあえずはWordPressが動けば個人的には問題ありません。
MariaDBの導入手順
(1)MariaDBのインストール
以下の黒背景部分はGNOME端末を表示しています。紫色はキーボードから入力するコマンド(コピペした方が楽ですが、コマンドは覚えられません)、緑はコマンドや処理内容の説明、白は自動表示する部分、赤は注意書きです。
#mariadb-serverをSCLoからインストール [root@ufuso ~]# yum --enablerepo=centos-sclo-rh -y install rh-mariadb101-mariadb-server インストール: rh-mariadb101-mariadb-server.x86_64 1:10.1.19-6.el7 依存性関連をインストールしました: audit-libs-python.x86_64 0:2.7.6-3.el7 checkpolicy.x86_64 0:2.5-4.el7 libcgroup.x86_64 0:0.41-13.el7 libsemanage-python.x86_64 0:2.5-8.el7 lsof.x86_64 0:4.87-4.el7 net-tools.x86_64 0:2.0-0.22.20131004git.el7 perl-Compress-Raw-Bzip2.x86_64 0:2.061-3.el7 perl-Compress-Raw-Zlib.x86_64 1:2.061-4.el7 perl-DBD-MySQL.x86_64 0:4.023-5.el7 perl-DBI.x86_64 0:1.627-4.el7 perl-IO-Compress.noarch 0:2.061-2.el7 perl-Net-Daemon.noarch 0:0.48-5.el7 perl-PlRPC.noarch 0:0.2020-14.el7 policycoreutils-python.x86_64 0:2.5-17.1.el7 python-IPy.noarch 0:0.75-6.el7 rh-mariadb101-mariadb.x86_64 1:10.1.19-6.el7 rh-mariadb101-mariadb-common.x86_64 1:10.1.19-6.el7 rh-mariadb101-mariadb-config.x86_64 1:10.1.19-6.el7 rh-mariadb101-mariadb-errmsg.x86_64 1:10.1.19-6.el7 rh-mariadb101-runtime.x86_64 0:2.2-3.el7 scl-utils.x86_64 0:20130529-18.el7_4 setools-libs.x86_64 0:3.3.8-1.1.el7 完了しました! |
(2)MariaDBの設定と起動
#rh-mariadb101を利用可能にする [root@ufuso ~]# scl enable rh-mariadb101 bash #mysqlのバージョン確認 [root@ufuso ~]# mysql -V mysql Ver 15.1 Distrib 10.1.19-MariaDB, for Linux (x86_64) using EditLine wrapper #mysqlの場所の確認 [root@ufuso ~]# which mysql /opt/rh/rh-mariadb101/root/usr/bin/mysql #環境変数を読み込むシェルの作成 [root@ufuso ~]# vi /etc/profile.d/rh-mariadb101.sh #以下の内容で新規作成 #!/bin/bash source /opt/rh/rh-mariadb101/enable export X_SCLS="`scl enable rh-mariadb101 'echo $X_SCLS'`" #mariadb-server.cnfの編集 [root@ufuso ~]# vi /etc/opt/rh/rh-mariadb101/my.cnf.d/mariadb-server.cnf ... ... [mysqld] datadir=/var/opt/rh/rh-mariadb101/lib/mysql socket=/var/lib/mysql/mysql.sock log-error=/var/opt/rh/rh-mariadb101/log/mariadb/mariadb.log pid-file=/var/run/rh-mariadb101-mariadb/mariadb.pid #追記 character-set-server=utf8 #rh-mariadb101-mariadb起動 [root@ufuso ~]# systemctl start rh-mariadb101-mariadb #rh-mariadb101-mariadb自動起動設定 [root@ufuso ~]# systemctl enable rh-mariadb101-mariadb Created symlink from /etc/systemd/system/multi-user.target.wants/rh-mariadb101-mariadb.service to /usr/lib/systemd/system/rh-mariadb101-mariadb.service. |
(3)MariaDBの動作確認
#MySQLのInstall [root@ufuso ~]# mysql_secure_installation 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キー押下 Enter current password for root (enter for none): OK, successfully used password, moving on... Setting the root password ensures that nobody can log into the MariaDB root user without the proper authorisation. #rootのパスワード作成でy入力 Set root password? [Y/n] y #rootのパスワード作成 New password: #rootのパスワード再入力 Re-enter new password: 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. #匿名ユーザーの削除でy入力 Remove anonymous users? [Y/n] 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. #rootでのログイン禁止でy入力 Disallow root login remotely? [Y/n] 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. #testデータベースの削除でy入力 Remove test database and access to it? [Y/n] 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. #権限テーブルの更新でy入力 Reload privilege tables now? [Y/n] 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パスワードでログイン [root@ufuso ~]# mysql -u root -p #rootパスワード入力しEnterキー押下 Enter password: Welcome to the MariaDB monitor. Commands end with ; or \g. Your MariaDB connection id is 10 Server version: 10.1.19-MariaDB MariaDB Server Copyright (c) 2000, 2016, Oracle, MariaDB Corporation Ab and others. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. #ホストの一覧表示 MariaDB [(none)]> select user,host,password from mysql.user; +------+-----------+-------------------------------------------+ | user | host | password | +------+-----------+-------------------------------------------+ | root | localhost | ***************************************** | | root | 127.0.0.1 | ***************************************** | | root | ::1 | ***************************************** | | xxxx | localhost | ***************************************** | +------+-----------+-------------------------------------------+ 4 rows in set (0.00 sec) #MySQLの終了 MariaDB [(none)]> exit Bye |
コメントを残す