前提
WordPress をインストールする前に WordPress 用の DB を構築するよ。
環境
Ubuntu 22.04
Nginx 1.22.1
MariaDB 10.6.11
MariaDB のインストールはこっちを見てね。
設定
設定前の確認
$ sudo mysql -u root -p
MariaDB [(none)]> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| sys |
+--------------------+
4 rows in set (0.016 sec)
MariaDB [(none)]> select user,host from mysql.user;
+-------------+-----------+
| User | Host |
+-------------+-----------+
| mariadb.sys | localhost |
| mysql | localhost |
| root | localhost |
+-------------+-----------+
3 rows in set (0.001 sec)
データベースの作成
MariaDB [(none)]> create database wordpress;
ユーザの作成
MariaDB [(none)]> create user 'wpuser'@'localhost' identified by 'p@ssw0rd';
アクセス権の付与(特権ユーザ)
MariaDB [(none)]> grant all on wordpress.* to 'wpuser'@'localhost' with grant option;
確認
MariaDB [(none)]> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| sys |
| wordpress |
+--------------------+
5 rows in set (0.002 sec)
MariaDB [(none)]> select user,host from mysql.user;
+-------------+-----------+
| User | Host |
+-------------+-----------+
| mariadb.sys | localhost |
| mysql | localhost |
| root | localhost |
| wpuser | localhost |
+-------------+-----------+
4 rows in set (0.002 sec)
設定保存
MariaDB [(none)]> flush privileges;
MariaDB [(none)]> quit