<コピペ用>MariaDBのインストール&初期設定&ワードプレス設定
MariaDBインストール
バージョン10.2をインストールします。
#最新版インストールのため、リポジトリ設定ファイル作成。
touch /etc/yum.repos.d/mariadb.repo
#リポジトリ設定記述。
echo -e "[mariadb]\nname = MariaDB\nbaseurl = http://yum.mariadb.org/10.2/centos7-amd64\ngpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB\ngpgcheck=1" >> /etc/yum.repos.d/mariadb.repo
#参考:記述内容
[mariadb]
name = MariaDB
baseurl = http://yum.mariadb.org/10.2/centos7-amd64
gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
gpgcheck=1
#MariaDBインストール
yum -y install MariaDB-server MariaDB-client
#MariaDBを起動
systemctl start mariadb.service
#MariaDBの自動起動設定ON
systemctl enable mariadb.service
MariaDBの初期設定
事前にMariaDB用のパスワードを用意しておいてください。
#MariaDBの初期設定を行う。
mysql_secure_installation
#次々と質問が現れるので、答えていく。
#YesはEnterで良い。
Enter current password for root (enter for none): #Enter
Set root password? [Y/n] #Enter
New password: #新規パスワードをコピペ
Re-enter new password: #新規パスワードを再度コピペ
Remove anonymous users? [Y/n] #Enter
Disallow root login remotely? [Y/n] #Enter
Remove test database and access to it? [Y/n] #Enter
Reload privilege tables now? [Y/n] #Enter
Thanks for using MariaDB! #おしまい
#次は設定ファイルの編集
#設定ファイルをバックアップ
cp /etc/my.cnf.d/server.cnf /etc/my.cnf.d/server.bak
#設定変更
sed -i -e "s/^\[mysqld\]/[mysqld]\ncharacter-set-server=utf8\ninnodb_buffer_pool_size = 512M\nquery_cache_size = 64M/g" /etc/my.cnf.d/server.cnf
#変更前
[mysqld]
#変更後
[mysqld]
character-set-server=utf8
innodb_buffer_pool_size = 512M
query_cache_size = 64M
#MariaDBを再起動
systemctl restart mariadb.service
新規ワードプレス用のデータベースを作成
事前にワードプレス用のパスワードを用意しておいてください。
#MariaDBにrootでログイン
mysql -u root -p
#この文字が出るので、rootのパスワードをコピペ
Enter password:
#この文字が出れば成功
MariaDB [(none)]>
#ワードプレス用のデータベースを作成(「wadopu1」の場合)。
create database wadopu1;
#そのデータベースを使うユーザーを作成(ユーザー「parudou」の場合)。
#パスワードはこのユーザー用に新たに作ったものをコピペ。
grant all privileges on wadopu1.* to parudou@localhost identified by 'パスワード';
#この文字が出れば成功
Query OK, 0 rows affected (0.01 sec)
以上です。
ワードプレスのインストールは次の記事にて。