XserverVPSでWordPress環境を構築していきます。Xserverでは無くとも、Ubuntuならば同様にできるようになっています。
3回目は、データベース管理システムのMariaDBのインストールについてです。
MariaDBのインストール
オープンソースのMySQLデータベース管理システムがオラクル社に買収された後、MySQLの元開発者たちがオープンソースとして開発したのがMariaDBです。MySQLと高い互換性があり、MySQLのデータベースやアプリケーションをMariaDBにそのまま移行できます。MySQLよりも迅速に改良が加えられています。
MySQLでも構いませんが、本記事ではMariaDBを採用します。
# apt -y install mariadb-server mariadb-client
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following additional packages will be installed:
galera-4 libcgi-fast-perl libcgi-pm-perl libclone-perl
libconfig-inifiles-perl libdaxctl1 libdbd-mysql-perl libdbi-perl
libencode-locale-perl libfcgi-bin libfcgi-perl libfcgi0t64
libhtml-parser-perl libhtml-tagset-perl libhtml-template-perl
libhttp-date-perl libhttp-message-perl libio-html-perl
liblwp-mediatypes-perl libmariadb3 libmysqlclient21 libndctl6 libpmem1
libsnappy1v5 libtimedate-perl liburi-perl liburing2 mariadb-client-core
mariadb-common mariadb-plugin-provider-bzip2 mariadb-plugin-provider-lz4
mariadb-plugin-provider-lzma mariadb-plugin-provider-lzo
mariadb-plugin-provider-snappy mariadb-server-core mysql-common pv socat
Suggested packages:
libmldbm-perl libnet-daemon-perl libsql-statement-perl libdata-dump-perl
libipc-sharedcache-perl libio-compress-brotli-perl libbusiness-isbn-perl
libregexp-ipv6-perl libwww-perl mailx mariadb-test doc-base
The following NEW packages will be installed:
galera-4 libcgi-fast-perl libcgi-pm-perl libclone-perl
libconfig-inifiles-perl libdaxctl1 libdbd-mysql-perl libdbi-perl
libencode-locale-perl libfcgi-bin libfcgi-perl libfcgi0t64
libhtml-parser-perl libhtml-tagset-perl libhtml-template-perl
libhttp-date-perl libhttp-message-perl libio-html-perl
liblwp-mediatypes-perl libmariadb3 libmysqlclient21 libndctl6 libpmem1
libsnappy1v5 libtimedate-perl liburi-perl liburing2 mariadb-client
mariadb-client-core mariadb-common mariadb-plugin-provider-bzip2
mariadb-plugin-provider-lz4 mariadb-plugin-provider-lzma
mariadb-plugin-provider-lzo mariadb-plugin-provider-snappy mariadb-server
mariadb-server-core mysql-common pv socat
0 upgraded, 40 newly installed, 0 to remove and 70 not upgraded.
Need to get 19.1 MB of archives.
After this operation, 198 MB of additional disk space will be used.
Get:1 http://nova.clouds.archive.ubuntu.com/ubuntu noble/universe amd64 galera-4 amd64 26.4.16-2build4 [736 kB]
Get:2 http://nova.clouds.archive.ubuntu.com/ubuntu noble/main amd64 mysql-common all 5.8+1.1.0build1 [6746 B]
Get:3 http://nova.clouds.archive.ubuntu.com/ubuntu noble/universe amd64 mariadb-common all 1:10.11.7-2ubuntu2 [26.7 kB]
Get:4 http://nova.clouds.archive.ubuntu.com/ubuntu noble/main amd64 libdbi-perl amd64 1.643-4build3 [721 kB]
Get:5 http://nova.clouds.archive.ubuntu.com/ubuntu noble/main amd64 libconfig-inifiles-perl all 3.000003-2 [39.4 kB]
Get:6 http://nova.clouds.archive.ubuntu.com/ubuntu noble/universe amd64 libmariadb3 amd64 1:10.11.7-2ubuntu2 [187 kB]
Get:7 http://nova.clouds.archive.ubuntu.com/ubuntu noble/universe amd64 mariadb-client-core amd64 1:10.11.7-2ubuntu2 [1009 kB]
Get:8 http://nova.clouds.archive.ubuntu.com/ubuntu noble/universe amd64 mariadb-client amd64 1:10.11.7-2ubuntu2 [2300 kB]
Get:9 http://nova.clouds.archive.ubuntu.com/ubuntu noble/main amd64 libdaxctl1 amd64 77-2ubuntu2 [21.4 kB]
Get:10 http://nova.clouds.archive.ubuntu.com/ubuntu noble/main amd64 libndctl6 amd64 77-2ubuntu2 [62.8 kB]
Get:11 http://nova.clouds.archive.ubuntu.com/ubuntu noble/main amd64 libpmem1 amd64 1.13.1-1.1ubuntu2 [84.8 kB]
Get:12 http://nova.clouds.archive.ubuntu.com/ubuntu noble/main amd64 liburing2 amd64 2.5-1build1 [21.1 kB]
Get:13 http://nova.clouds.archive.ubuntu.com/ubuntu noble/universe amd64 mariadb-server-core amd64 1:10.11.7-2ubuntu2 [7964 kB]
Get:14 http://nova.clouds.archive.ubuntu.com/ubuntu noble/main amd64 socat amd64 1.8.0.0-4build3 [374 kB]
Get:15 http://nova.clouds.archive.ubuntu.com/ubuntu noble/universe amd64 mariadb-server amd64 1:10.11.7-2ubuntu2 [3380 kB]
Get:16 http://nova.clouds.archive.ubuntu.com/ubuntu noble/main amd64 libhtml-tagset-perl all 3.20-6 [11.3 kB]
Get:17 http://nova.clouds.archive.ubuntu.com/ubuntu noble/main amd64 liburi-perl all 5.27-1 [88.0 kB]
Get:18 http://nova.clouds.archive.ubuntu.com/ubuntu noble/main amd64 libhtml-parser-perl amd64 3.81-1build3 [85.8 kB]
Get:19 http://nova.clouds.archive.ubuntu.com/ubuntu noble/main amd64 libcgi-pm-perl all 4.63-1 [185 kB]
Get:20 http://nova.clouds.archive.ubuntu.com/ubuntu noble/main amd64 libfcgi0t64 amd64 2.4.2-2.1build1 [26.8 kB]
Get:21 http://nova.clouds.archive.ubuntu.com/ubuntu noble/main amd64 libfcgi-perl amd64 0.82+ds-3build2 [21.7 kB]
Get:22 http://nova.clouds.archive.ubuntu.com/ubuntu noble/main amd64 libcgi-fast-perl all 1:2.17-1 [10.3 kB]
Get:23 http://nova.clouds.archive.ubuntu.com/ubuntu noble/main amd64 libclone-perl amd64 0.46-1build3 [10.7 kB]
Get:24 http://nova.clouds.archive.ubuntu.com/ubuntu noble-updates/main amd64 libmysqlclient21 amd64 8.0.37-0ubuntu0.24.04.1 [1254 kB]
Get:25 http://nova.clouds.archive.ubuntu.com/ubuntu noble/universe amd64 libdbd-mysql-perl amd64 4.052-1ubuntu3 [85.5 kB]
Get:26 http://nova.clouds.archive.ubuntu.com/ubuntu noble/main amd64 libencode-locale-perl all 1.05-3 [11.6 kB]
Get:27 http://nova.clouds.archive.ubuntu.com/ubuntu noble/main amd64 libfcgi-bin amd64 2.4.2-2.1build1 [11.2 kB]
Get:28 http://nova.clouds.archive.ubuntu.com/ubuntu noble/main amd64 libhtml-template-perl all 2.97-2 [60.2 kB]
Get:29 http://nova.clouds.archive.ubuntu.com/ubuntu noble/main amd64 libtimedate-perl all 2.3300-2 [34.0 kB]
Get:30 http://nova.clouds.archive.ubuntu.com/ubuntu noble/main amd64 libhttp-date-perl all 6.06-1 [10.2 kB]
Get:31 http://nova.clouds.archive.ubuntu.com/ubuntu noble/main amd64 libio-html-perl all 1.004-3 [15.9 kB]
Get:32 http://nova.clouds.archive.ubuntu.com/ubuntu noble/main amd64 liblwp-mediatypes-perl all 6.04-2 [20.1 kB]
Get:33 http://nova.clouds.archive.ubuntu.com/ubuntu noble/main amd64 libhttp-message-perl all 6.45-1ubuntu1 [78.2 kB]
Get:34 http://nova.clouds.archive.ubuntu.com/ubuntu noble/universe amd64 mariadb-plugin-provider-bzip2 amd64 1:10.11.7-2ubuntu2 [13.9 kB]
Get:35 http://nova.clouds.archive.ubuntu.com/ubuntu noble/universe amd64 mariadb-plugin-provider-lz4 amd64 1:10.11.7-2ubuntu2 [13.8 kB]
Get:36 http://nova.clouds.archive.ubuntu.com/ubuntu noble/universe amd64 mariadb-plugin-provider-lzma amd64 1:10.11.7-2ubuntu2 [13.9 kB]
Get:37 http://nova.clouds.archive.ubuntu.com/ubuntu noble/universe amd64 mariadb-plugin-provider-lzo amd64 1:10.11.7-2ubuntu2 [13.8 kB]
Get:38 http://nova.clouds.archive.ubuntu.com/ubuntu noble/main amd64 libsnappy1v5 amd64 1.1.10-1build1 [28.6 kB]
Get:39 http://nova.clouds.archive.ubuntu.com/ubuntu noble/universe amd64 mariadb-plugin-provider-snappy amd64 1:10.11.7-2ubuntu2 [13.8 kB]
Get:40 http://nova.clouds.archive.ubuntu.com/ubuntu noble/main amd64 pv amd64 1.8.5-2build1 [73.9 kB]
Fetched 19.1 MB in 5s (3909 kB/s)
Extracting templates from packages: 100%
Preconfiguring packages ...
Selecting previously unselected package galera-4.
(Reading database ... 67862 files and directories currently installed.)
Preparing to unpack .../00-galera-4_26.4.16-2build4_amd64.deb ...
info: The home dir /nonexistent you specified can't be accessed: No such file or directory
info: Selecting UID from range 100 to 999 ...
info: Adding system user `_galera' (UID 109) ...
info: Adding new user `_galera' (UID 109) with group `nogroup' ...
info: Not creating `/nonexistent'.
Unpacking galera-4 (26.4.16-2build4) ...
Selecting previously unselected package mysql-common.
Preparing to unpack .../01-mysql-common_5.8+1.1.0build1_all.deb ...
Unpacking mysql-common (5.8+1.1.0build1) ...
Selecting previously unselected package mariadb-common.
Preparing to unpack .../02-mariadb-common_1%3a10.11.7-2ubuntu2_all.deb ...
Unpacking mariadb-common (1:10.11.7-2ubuntu2) ...
Selecting previously unselected package libdbi-perl:amd64.
Preparing to unpack .../03-libdbi-perl_1.643-4build3_amd64.deb ...
Unpacking libdbi-perl:amd64 (1.643-4build3) ...
Selecting previously unselected package libconfig-inifiles-perl.
Preparing to unpack .../04-libconfig-inifiles-perl_3.000003-2_all.deb ...
Unpacking libconfig-inifiles-perl (3.000003-2) ...
Selecting previously unselected package libmariadb3:amd64.
Preparing to unpack .../05-libmariadb3_1%3a10.11.7-2ubuntu2_amd64.deb ...
Unpacking libmariadb3:amd64 (1:10.11.7-2ubuntu2) ...
Selecting previously unselected package mariadb-client-core.
Preparing to unpack .../06-mariadb-client-core_1%3a10.11.7-2ubuntu2_amd64.deb ...
Unpacking mariadb-client-core (1:10.11.7-2ubuntu2) ...
Selecting previously unselected package mariadb-client.
Preparing to unpack .../07-mariadb-client_1%3a10.11.7-2ubuntu2_amd64.deb ...
Unpacking mariadb-client (1:10.11.7-2ubuntu2) ...
Selecting previously unselected package libdaxctl1:amd64.
Preparing to unpack .../08-libdaxctl1_77-2ubuntu2_amd64.deb ...
Unpacking libdaxctl1:amd64 (77-2ubuntu2) ...
Selecting previously unselected package libndctl6:amd64.
Preparing to unpack .../09-libndctl6_77-2ubuntu2_amd64.deb ...
Unpacking libndctl6:amd64 (77-2ubuntu2) ...
Selecting previously unselected package libpmem1:amd64.
Preparing to unpack .../10-libpmem1_1.13.1-1.1ubuntu2_amd64.deb ...
Unpacking libpmem1:amd64 (1.13.1-1.1ubuntu2) ...
Selecting previously unselected package liburing2:amd64.
Preparing to unpack .../11-liburing2_2.5-1build1_amd64.deb ...
Unpacking liburing2:amd64 (2.5-1build1) ...
Selecting previously unselected package mariadb-server-core.
Preparing to unpack .../12-mariadb-server-core_1%3a10.11.7-2ubuntu2_amd64.deb ...
Unpacking mariadb-server-core (1:10.11.7-2ubuntu2) ...
Selecting previously unselected package socat.
Preparing to unpack .../13-socat_1.8.0.0-4build3_amd64.deb ...
Unpacking socat (1.8.0.0-4build3) ...
Setting up mysql-common (5.8+1.1.0build1) ...
update-alternatives: using /etc/mysql/my.cnf.fallback to provide /etc/mysql/my.cnf (my.cnf) in auto mode
Setting up mariadb-common (1:10.11.7-2ubuntu2) ...
update-alternatives: using /etc/mysql/mariadb.cnf to provide /etc/mysql/my.cnf (my.cnf) in auto mode
Selecting previously unselected package mariadb-server.
(Reading database ... 68353 files and directories currently installed.)
Preparing to unpack .../00-mariadb-server_1%3a10.11.7-2ubuntu2_amd64.deb ...
Unpacking mariadb-server (1:10.11.7-2ubuntu2) ...
Selecting previously unselected package libhtml-tagset-perl.
Preparing to unpack .../01-libhtml-tagset-perl_3.20-6_all.deb ...
Unpacking libhtml-tagset-perl (3.20-6) ...
Selecting previously unselected package liburi-perl.
Preparing to unpack .../02-liburi-perl_5.27-1_all.deb ...
Unpacking liburi-perl (5.27-1) ...
Selecting previously unselected package libhtml-parser-perl:amd64.
Preparing to unpack .../03-libhtml-parser-perl_3.81-1build3_amd64.deb ...
Unpacking libhtml-parser-perl:amd64 (3.81-1build3) ...
Selecting previously unselected package libcgi-pm-perl.
Preparing to unpack .../04-libcgi-pm-perl_4.63-1_all.deb ...
Unpacking libcgi-pm-perl (4.63-1) ...
Selecting previously unselected package libfcgi0t64:amd64.
Preparing to unpack .../05-libfcgi0t64_2.4.2-2.1build1_amd64.deb ...
Unpacking libfcgi0t64:amd64 (2.4.2-2.1build1) ...
Selecting previously unselected package libfcgi-perl.
Preparing to unpack .../06-libfcgi-perl_0.82+ds-3build2_amd64.deb ...
Unpacking libfcgi-perl (0.82+ds-3build2) ...
Selecting previously unselected package libcgi-fast-perl.
Preparing to unpack .../07-libcgi-fast-perl_1%3a2.17-1_all.deb ...
Unpacking libcgi-fast-perl (1:2.17-1) ...
Selecting previously unselected package libclone-perl:amd64.
Preparing to unpack .../08-libclone-perl_0.46-1build3_amd64.deb ...
Unpacking libclone-perl:amd64 (0.46-1build3) ...
Selecting previously unselected package libmysqlclient21:amd64.
Preparing to unpack .../09-libmysqlclient21_8.0.37-0ubuntu0.24.04.1_amd64.deb ...
Unpacking libmysqlclient21:amd64 (8.0.37-0ubuntu0.24.04.1) ...
Selecting previously unselected package libdbd-mysql-perl:amd64.
Preparing to unpack .../10-libdbd-mysql-perl_4.052-1ubuntu3_amd64.deb ...
Unpacking libdbd-mysql-perl:amd64 (4.052-1ubuntu3) ...
Selecting previously unselected package libencode-locale-perl.
Preparing to unpack .../11-libencode-locale-perl_1.05-3_all.deb ...
Unpacking libencode-locale-perl (1.05-3) ...
Selecting previously unselected package libfcgi-bin.
Preparing to unpack .../12-libfcgi-bin_2.4.2-2.1build1_amd64.deb ...
Unpacking libfcgi-bin (2.4.2-2.1build1) ...
Selecting previously unselected package libhtml-template-perl.
Preparing to unpack .../13-libhtml-template-perl_2.97-2_all.deb ...
Unpacking libhtml-template-perl (2.97-2) ...
Selecting previously unselected package libtimedate-perl.
Preparing to unpack .../14-libtimedate-perl_2.3300-2_all.deb ...
Unpacking libtimedate-perl (2.3300-2) ...
Selecting previously unselected package libhttp-date-perl.
Preparing to unpack .../15-libhttp-date-perl_6.06-1_all.deb ...
Unpacking libhttp-date-perl (6.06-1) ...
Selecting previously unselected package libio-html-perl.
Preparing to unpack .../16-libio-html-perl_1.004-3_all.deb ...
Unpacking libio-html-perl (1.004-3) ...
Selecting previously unselected package liblwp-mediatypes-perl.
Preparing to unpack .../17-liblwp-mediatypes-perl_6.04-2_all.deb ...
Unpacking liblwp-mediatypes-perl (6.04-2) ...
Selecting previously unselected package libhttp-message-perl.
Preparing to unpack .../18-libhttp-message-perl_6.45-1ubuntu1_all.deb ...
Unpacking libhttp-message-perl (6.45-1ubuntu1) ...
Selecting previously unselected package mariadb-plugin-provider-bzip2.
Preparing to unpack .../19-mariadb-plugin-provider-bzip2_1%3a10.11.7-2ubuntu2_amd64.deb ...
Unpacking mariadb-plugin-provider-bzip2 (1:10.11.7-2ubuntu2) ...
Selecting previously unselected package mariadb-plugin-provider-lz4.
Preparing to unpack .../20-mariadb-plugin-provider-lz4_1%3a10.11.7-2ubuntu2_amd64.deb ...
Unpacking mariadb-plugin-provider-lz4 (1:10.11.7-2ubuntu2) ...
Selecting previously unselected package mariadb-plugin-provider-lzma.
Preparing to unpack .../21-mariadb-plugin-provider-lzma_1%3a10.11.7-2ubuntu2_amd64.deb ...
Unpacking mariadb-plugin-provider-lzma (1:10.11.7-2ubuntu2) ...
Selecting previously unselected package mariadb-plugin-provider-lzo.
Preparing to unpack .../22-mariadb-plugin-provider-lzo_1%3a10.11.7-2ubuntu2_amd64.deb ...
Unpacking mariadb-plugin-provider-lzo (1:10.11.7-2ubuntu2) ...
Selecting previously unselected package libsnappy1v5:amd64.
Preparing to unpack .../23-libsnappy1v5_1.1.10-1build1_amd64.deb ...
Unpacking libsnappy1v5:amd64 (1.1.10-1build1) ...
Selecting previously unselected package mariadb-plugin-provider-snappy.
Preparing to unpack .../24-mariadb-plugin-provider-snappy_1%3a10.11.7-2ubuntu2_amd64.deb ...
Unpacking mariadb-plugin-provider-snappy (1:10.11.7-2ubuntu2) ...
Selecting previously unselected package pv.
Preparing to unpack .../25-pv_1.8.5-2build1_amd64.deb ...
Unpacking pv (1.8.5-2build1) ...
Setting up libconfig-inifiles-perl (3.000003-2) ...
Setting up galera-4 (26.4.16-2build4) ...
Setting up libmysqlclient21:amd64 (8.0.37-0ubuntu0.24.04.1) ...
Setting up libclone-perl:amd64 (0.46-1build3) ...
Setting up libfcgi0t64:amd64 (2.4.2-2.1build1) ...
Setting up libhtml-tagset-perl (3.20-6) ...
Setting up liblwp-mediatypes-perl (6.04-2) ...
Setting up libfcgi-bin (2.4.2-2.1build1) ...
Setting up libencode-locale-perl (1.05-3) ...
Setting up libsnappy1v5:amd64 (1.1.10-1build1) ...
Setting up socat (1.8.0.0-4build3) ...
Setting up libio-html-perl (1.004-3) ...
Setting up libmariadb3:amd64 (1:10.11.7-2ubuntu2) ...
Setting up libdaxctl1:amd64 (77-2ubuntu2) ...
Setting up libtimedate-perl (2.3300-2) ...
Setting up pv (1.8.5-2build1) ...
Setting up libndctl6:amd64 (77-2ubuntu2) ...
Setting up libfcgi-perl (0.82+ds-3build2) ...
Setting up liburing2:amd64 (2.5-1build1) ...
Setting up libpmem1:amd64 (1.13.1-1.1ubuntu2) ...
Setting up liburi-perl (5.27-1) ...
Setting up libdbi-perl:amd64 (1.643-4build3) ...
Setting up libhttp-date-perl (6.06-1) ...
Setting up mariadb-client-core (1:10.11.7-2ubuntu2) ...
Setting up libdbd-mysql-perl:amd64 (4.052-1ubuntu3) ...
Setting up libhtml-parser-perl:amd64 (3.81-1build3) ...
Setting up mariadb-server-core (1:10.11.7-2ubuntu2) ...
Setting up libhttp-message-perl (6.45-1ubuntu1) ...
Setting up mariadb-client (1:10.11.7-2ubuntu2) ...
Setting up libcgi-pm-perl (4.63-1) ...
Setting up libhtml-template-perl (2.97-2) ...
Setting up mariadb-server (1:10.11.7-2ubuntu2) ...
Created symlink /etc/systemd/system/multi-user.target.wants/mariadb.service → /usr/lib/systemd/system/mariadb.service.
Setting up mariadb-plugin-provider-bzip2 (1:10.11.7-2ubuntu2) ...
Setting up mariadb-plugin-provider-lzma (1:10.11.7-2ubuntu2) ...
Setting up mariadb-plugin-provider-lzo (1:10.11.7-2ubuntu2) ...
Setting up mariadb-plugin-provider-lz4 (1:10.11.7-2ubuntu2) ...
Setting up libcgi-fast-perl (1:2.17-1) ...
Setting up mariadb-plugin-provider-snappy (1:10.11.7-2ubuntu2) ...
Processing triggers for man-db (2.12.0-4build2) ...
Processing triggers for libc-bin (2.39-0ubuntu8) ...
Processing triggers for mariadb-server (1:10.11.7-2ubuntu2) ...
Scanning processes...
Scanning linux images...
Running kernel seems to be up-to-date.
No services need to be restarted.
No containers need to be restarted.
No user sessions are running outdated binaries.
No VM guests are running outdated hypervisor (qemu) binaries on this host.
MariaDBのバージョン確認
# mysql --version
mysql Ver 15.1 Distrib 10.11.7-MariaDB, for debian-linux-gnu (x86_64) using EditLine wrapper
MariaDBはMySQLと互換性があるため、コマンドはmysqlとなることに留意してください。
MariaDBの初期設定
対話型で指定していくので、赤字のコメントを参考にしながら入力してください。
# 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
haven't set the root password yet, you should just press enter here.
Enter current password for root (enter for none): ←パスワードは未設定なのでエンターキーを押す。
OK, successfully used password, moving on...
Setting the root password or using the unix_socket ensures that nobody
can log into the MariaDB root user without the proper authorisation.
You already have your root account protected, so you can safely answer 'n'.
Switch to unix_socket authentication [Y/n] n ←nでUbuntuのrootのパスワードをそのまま適用しない。
... skipping.
You already have your root account protected, so you can safely answer 'n'.
Change the root password? [Y/n] Y ←パスワードが未設定なので、Yでパスワードを設定。
New password: ←新しいパスワードを入力
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.
Remove anonymous users? [Y/n] Y ←最初から設定されているanonymousユーザーを削除。
... 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 ←リモートでrootユーザーによる接続を禁止。
... 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 ←用意されているtestのデータベースを削除
- 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 ←権限情報テーブルの再読み込み
... 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!
設定ファイルの場所を確認
# ls /etc/mysql/mariadb.conf.d
50-client.cnf 60-galera.cnf provider_lzo.cnf
50-mysql-clients.cnf provider_bzip2.cnf provider_snappy.cnf
50-mysqld_safe.cnf provider_lz4.cnf
50-server.cnf provider_lzma.cnf
このディレクトリにMariaDBの各設定ファイルが設置されています。
MariaDBサーバーの設定を変更
viエディタでの作業で説明しますが、別のエディタでも構いません。
# vi /etc/mysql/mariadb.conf.d/50-server.cnf
エラーログの出力
/error で下記の場所を探します。
#log_error = /var/log/mysql/error.log
iキーでインサートモードにしてコメントアウトの#を削除します。
log_error = /var/log/mysql/error.log
:wqで保存して終了します。
修正後は下のようになります。
#
# These groups are read by MariaDB server.
# Use it for options that only the server (but not clients) should see
# this is read by the standalone daemon and embedded servers
[server]
# this is only for the mysqld standalone daemon
[mysqld]
#
# * Basic Settings
#
#user = mysql
pid-file = /run/mysqld/mysqld.pid
basedir = /usr
#datadir = /var/lib/mysql
#tmpdir = /tmp
# Broken reverse DNS slows down connections considerably and name resolve is
# safe to skip if there are no "host by domain name" access grants
#skip-name-resolve
# Instead of skip-networking the default is now to listen only on
# localhost which is more compatible and is not less secure.
bind-address = 127.0.0.1
#
# * Fine Tuning
#
#key_buffer_size = 128M
#max_allowed_packet = 1G
#thread_stack = 192K
#thread_cache_size = 8
# This replaces the startup script and checks MyISAM tables if needed
# the first time they are touched
#myisam_recover_options = BACKUP
#max_connections = 100
#table_cache = 64
#
# * Logging and Replication
#
# Note: The configured log file or its directory need to be created
# and be writable by the mysql user, e.g.:
# $ sudo mkdir -m 2750 /var/log/mysql
# $ sudo chown mysql /var/log/mysql
# Both location gets rotated by the cronjob.
# Be aware that this log type is a performance killer.
# Recommend only changing this at runtime for short testing periods if needed!
#general_log_file = /var/log/mysql/mysql.log
#general_log = 1
# When running under systemd, error logging goes via stdout/stderr to journald
# and when running legacy init error logging goes to syslog due to
# /etc/mysql/conf.d/mariadb.conf.d/50-mysqld_safe.cnf
# Enable this if you want to have error logging into a separate file
log_error = /var/log/mysql/error.log
# Enable the slow query log to see queries with especially long duration
#log_slow_query_file = /var/log/mysql/mariadb-slow.log
#log_slow_query_time = 10
#log_slow_verbosity = query_plan,explain
#log-queries-not-using-indexes
#log_slow_min_examined_row_limit = 1000
# The following can be used as easy to replay backup logs or for replication.
# note: if you are setting up a replica, see README.Debian about other
# settings you may need to change.
#server-id = 1
#log_bin = /var/log/mysql/mysql-bin.log
expire_logs_days = 10
#max_binlog_size = 100M
#
# * SSL/TLS
#
# For documentation, please read
# https://mariadb.com/kb/en/securing-connections-for-client-and-server/
#ssl-ca = /etc/mysql/cacert.pem
#ssl-cert = /etc/mysql/server-cert.pem
#ssl-key = /etc/mysql/server-key.pem
#require-secure-transport = on
#
# * Character sets
#
# MySQL/MariaDB default is Latin1, but in Debian we rather default to the full
# utf8 4-byte character set. See also client.cnf
character-set-server = utf8mb4
collation-server = utf8mb4_general_ci
#
# * InnoDB
#
# InnoDB is enabled by default with a 10MB datafile in /var/lib/mysql/.
# Read the manual for more InnoDB related options. There are many!
# Most important is to give InnoDB 80 % of the system RAM for buffer use:
# https://mariadb.com/kb/en/innodb-system-variables/#innodb_buffer_pool_size
#innodb_buffer_pool_size = 8G
# this is only for embedded server
[embedded]
# This group is only read by MariaDB servers, not by MySQL.
# If you use the same .cnf file for MySQL and MariaDB,
# you can put MariaDB-only options here
[mariadb]
# This group is only read by MariaDB-10.11 servers.
# If you use the same .cnf file for MariaDB of different versions,
# use this group for options that older servers don't understand
[mariadb-10.11]
MariaDBユーザーの作成
MariaDB(MySQL)のユーザーはWordPressで必要になります。
MariaDB(MySQL)に入ります。
# mysql -u root -p
Enter password:
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 40
Server version: 10.11.7-MariaDB-2ubuntu2 Ubuntu 24.04
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でユーザー作成のコマンドを入力します。
MariaDB [(none)]> create user admin@'%' identified by 'password';
Query OK, 0 rows affected (0.001 sec)
この例ではadminというユーザーでパスワードをpasswordとして登録しました。
(別途、WordPressのインストールの記事でも説明します。今回はやり方の紹介です。)
MairiaDBを抜けます。
exitで抜けることができます。
MariaDB [(none)]> exit
Bye
MariaDB用3306ポートの開放
FireWallで3306ポートを開放します。
MariaDB(MySQL)に対して外部から接続する際にポートを開けておく必要があります。
外部からの接続が不要なら開ける必要はありません。
(WordPressの利用のみであれば、3306ポート開放は不要です。)
# ufw allow 3306
Rules updated
Rules updated (v6)
VPSの場合は、VPSの管理画面でもポートを開けておく必要があります。
XserverVPSでのポートの開け方はこちらの記事のパケットフィルターの設定を参考にしてください。
ご覧いただき有難うございました。良かったら いいね(thumb up)ボタンをお願いします。
PR
コメント