MariaDB is the database layer — where WordPress stores everything: posts, pages, users, settings, plugin data, transients. Getting it installed and configured correctly is one of the less glamorous parts of stack setup, but the steps are straightforward.
Why MariaDB and Not MySQL
Rocky Linux 9 ships MariaDB as the default database package. MariaDB is a community-maintained fork of MySQL created after Oracle’s acquisition of MySQL in 2010. For WordPress, the difference is invisible — same SQL syntax, same connection method, same wp-config.php settings.
If a tutorial says MySQL, follow it with MariaDB. They’re interchangeable for this purpose.
Step 1 — Install MariaDB
sudo dnf install mariadb-server -y
Step 2 — Enable and Start
sudo systemctl enable --now mariadb
Verify it’s running:
sudo systemctl status mariadb
active (running) — good to continue.
Step 3 — Run mysql_secure_installation
This script walks through basic security setup — setting a root password and removing test data that ships with the default installation:
sudo mysql_secure_installation
You’ll be asked several questions. Here’s what to answer:
Enter current password for root (enter for none): [press Enter]
Switch to unix_socket authentication [Y/n]: n
Change the root password? [Y/n]: Y
New password: [set a strong password — write it down]
Re-enter new password: [confirm]
Remove anonymous users? [Y/n]: Y
Disallow root login remotely? [Y/n]: Y
Remove test database and access to it? [Y/n]: Y
Reload privilege tables now? [Y/n]: Y
The root password you set here is the MariaDB root password — separate from your Linux system root password.
Step 4 — Log In to MariaDB
Test the root login with the password you just set:
mysql -u root -p
Enter the password when prompted. You should see the MariaDB prompt:
MariaDB [(none)]>
You’re now inside the MariaDB shell. Commands here end with a semicolon.
Step 5 — Create the WordPress Database
Still in the MariaDB shell:
CREATE DATABASE wordpress_site CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
Replace wordpress_site with whatever name you prefer. Keep it simple — no spaces, lowercase, underscores if needed. utf8mb4 is the correct character set for WordPress — it supports emoji and all Unicode characters.
Step 6 — Create a Dedicated User
CREATE USER 'wp_user'@'localhost' IDENTIFIED BY 'your-strong-password-here';
GRANT ALL PRIVILEGES ON wordpress_site.* TO 'wp_user'@'localhost';
FLUSH PRIVILEGES;
Three things to choose and remember:
wp_user— the database username (pick anything)your-strong-password-here— the database password (not your root password)wordpress_site— must match the database name you created above
GRANT ALL PRIVILEGES ON wordpress_site.* gives this user full access to the WordPress database only — not to any other database on the server. If this user’s credentials end up in the wrong hands, the damage is limited to one site’s data.
The Root vs Dedicated User Question
Using root for WordPress is something a lot of people do, especially on personal servers with one or two sites. It’s faster to set up and the site works identically. I’ve done it.
The tradeoff: root has access to every database on the server. WordPress stores the database credentials in wp-config.php. If WordPress gets compromised — via an exploited plugin, for example — and the attacker extracts wp-config.php, they now have credentials that reach every database on the machine.
With a dedicated user, wp-config.php contains credentials that only reach one database. Containment.
For a single personal site on a VPS you fully control: root is convenient and the risk is manageable. For multiple sites or anything with real traffic or sensitive data: dedicated user per site, every time.
Step 7 — Verify and Exit
Confirm the database exists:
SHOW DATABASES;
You should see wordpress_site (or whatever you named it) in the list.
Confirm the user exists:
SELECT User, Host FROM mysql.user;
Exit MariaDB:
exit;
Write Down These Three Things
Before moving to the next article, record:
Database name: wordpress_site
Database user: wp_user
Database password: [whatever you set]
Database host: localhost
These go into wp-config.php in Part 5. If you’re the kind of person who has to run a SHOW DATABASES; to remember what you named things — which is a reasonable way to operate — at least write them in a project note before closing this session.
Useful MariaDB Commands Reference
# Log in as root
mysql -u root -p
# Log in as a specific user
mysql -u wp_user -p wordpress_site
-- Show all databases
SHOW DATABASES;
-- Show all users
SELECT User, Host FROM mysql.user;
-- Show user permissions
SHOW GRANTS FOR 'wp_user'@'localhost';
-- Select a database to work with
USE wordpress_site;
-- Show tables in current database
SHOW TABLES;
-- Exit
exit;