Unknown column 'wp_' in 'field list' when running WordPress on PHP 8.1

Viewed 2282

Is it possible to run Wordpress on PHP 8.1 right now? I have installed PHP 8.1 in XAMPP, but I can't get Wordpress to work. I get this error message:

[23-Nov-2021 18:44:43 UTC] PHP Fatal error: Uncaught mysqli_sql_exception: Unknown column 'wp_' in 'field list' in C:\xampp\htdocs\my_php_81_folder\normal_local_site\wp-includes\wp-db.php:2056 Stack trace: #0 C:\xampp\htdocs\my_php_81_folder\normal_local_site\wp-includes\wp-db.php(2056): mysqli_query(Object(mysqli), 'SELECT wp_') #1 C:\xampp\htdocs\my_php_81_folder\normal_local_site\wp-includes\wp-db.php(1945): wpdb->do_query('SELECT wp') #2 C:\xampp\htdocs\my_php_81_folder\normal_local_site\wp-admin\setup-config.php(317): wpdb->query('SELECT wp_') #3 {main} thrown in C:\xampp\htdocs\my_php_81_folder\normal_local_site\wp-includes\wp-db.php on line 2056 [23-Nov-2021 18:45:45 UTC] PHP Fatal error: Uncaught mysqli_sql_exception: Unknown column 'wp_' in 'field list' in C:\xampp\htdocs\my_php_81_folder\normal_local_site\wp-includes\wp-db.php:2056

I have verified that PHP 8.1 is being served to this folder and I can run PDO and mysqli commands that successfully create and modify local databases.

2 Answers

As of November 2021* WordPress is not yet fully compatible with PHP 8.1. The WordPress 5.9 release that is planned to be available on 25th January 2022 should be compatible with PHP 8.1.

For the time being, please use PHP 8.0 with WordPress to avoid weird bugs.

* PHP 8.1 was released on 25th November 2021

For anyone who reaches this in the next couple days before Wordpress 5.9 comes out, I was able to get 5.8.3 working on PHP 8.1 by making a quick change to wp-includes/wp-db.php. I added this line after if ( $this->use_mysqli ) in the db_connect method (line 1630):

mysqli_report(MYSQLI_REPORT_OFF);

This change is one made in Wordpress 5.9 itself, so should be fine.

Related