Whoops - First Step in Bug Hunting

The first thing we want to do is to put WordPress into Debug mode. To do this edit the wpconfig.php file and change WP_DEBUG to TRUE:

define( 'WP_DEBUG', true );
define( 'WP_DEBUG', true );

Refresh your browser and you will see more information on whatever error you are seeing.

IBM i WordPress - Error Examples

(1) Internal Server Error

This normally happens when your HTTP Server or PHP Server is not active, or the port is blocked - either way my browser cannot find the webserver:

Internal Server Error

(2) Error establishing a database connection

Good News - PHP Server Connection OK

Bad News - Cannot access database

So, this means WordPress tried to connect to your MariaDB/MySQL server, but the connection was blocked before it even reached the database.

This is not a wrong password error. This is not a missing database error.

It means the PHP process does not have permission to open a network/socket connection to MySQL.

This is a huge step in the right direction - it means my IBM-i PHP Server is working, the port is correct and I am talking to WordPress. The bad news is that WordPress is not happy with something about the database connection and how we have configured it!

Error establishing a database connection

Hmmmmmmmmmmm.

So, my first thought was to check that my user MYSQL can access the data base correctly. I launched a terminal in VS-Code, happily connected to the database and attempted to read it. Then, darkly happy, I see an access/authority problem:

Verify User Access to IBM-i MySQL Database

Solution Attempt 1 -- Create a new database while signed in as MYSQL

Start a new terminal and login with the user account what we are using in our /www/your-php-server/htdocs/wp-config.php

/usr/local/mariadb/bin/mysql -u MYSQLUSER -p

Once logged in we will create a new database for our WordPress install to live in. Let's called it "WordPress2026" : 

CREATE DATABASE WordPress2026;

But this did NOT solve my problem!   🙁

Solution Attempt 2 -- Check that LOCALHOST is accessible

Test from the command line (same user as Apache/PHP)

If you can, run:

/QOpenSys/pkgs/bin/mysql -u MYSQLUSER -p -h localhost

If that fails with permission denied, it’s definitely a socket or authority issue.

If that works then let's try switching WordPress to TCP instead of socket

In wp-config.php, change:

define( 'DB_HOST', 'localhost' );

to:

define( 'DB_HOST', '127.0.0.1' );

This forces WordPress to use TCP instead of the socket, which is often the simplest fix on IBM i.

{"email":"Email address invalid","url":"Website address invalid","required":"Required field missing"}
>