Support » Localhost Installs » setup-config.php throws ‘WordPress database error Unknown column’

  • I’m trying to install WordPress on Ubuntu (more precisely, Ubuntu Mate 21.04 desktop 64b run in a VirtualBox VM)

    Problem is that when I open my localhost WordPress installation for the first time and click through the famous 5-minute installer then as soon as I enter database details and click Submit the following error appears in /var/log/apache2/error.log:

    [Sun Aug 08 18:37:28.141296 2021] [proxy_fcgi:error] [pid 19693:tid 140137111639616] [client 127.0.0.1:44772] AH01071: Got error 'PHP message: WordPress database error Unknown column 'wp_' in 'field list' for query SELECT wp_PHP message: WordPress database error Incorrect table name '' for query INSERT INTO `` (`option_name`, `option_value`, `autoload`) VALUES ('nonce_key', '-l;6hq@?fr/*VUp9p_B^+,Aj/S8!j|#H%pIWy`0i!OXWQx3AuNwwPhK4{V2{/u3}', 'no') ON DUPLICATE KEY UPDATE `option_name` = VALUES(`option_name`), `option_value` = VALUES(`option_value`), `autoload` = VALUES(`autoload`) made by wp_print_scripts, wp_scripts, WP_Scripts->__construct, WP_Scripts->init, do_action_ref_array('wp_default_scripts'), WP_Hook->do_action, WP_Hook->apply_filters, wp_default_scripts, wp_create_nonce, wp_hash, wp_salt, update_site_option, update_network_option, add_network_option, add_optionPHP message: WordPress database error Incorrect table name '' for query INSERT INTO `` (`option_name`, `option_value`, `autoload`) VALUES ('nonce_salt', 'lz`4ap}SeckS-{*B;S>#DrQ5*MBa|G,_0>R0?fJruKs_o4J-+4C7~#ef?/&U?sh|', 'no') ON DUPLICATE KEY UPDATE `option_name` = VALUES(`option_name`), `option_value` = VALUES(`option_value`), `autoload` = VALUES(`autoload`) made by wp_print_scripts, wp_scripts, WP_Scripts->__construct, WP_Scripts->init, do_action_ref_array('wp_default_scripts'), WP_Hook->do_action, WP_Hook->apply_filters, wp_default_scripts, wp_create_nonce, wp_hash, wp_salt, update_site_option, update_network_option, add_network_option, add_option', referer: http://localhost/wp-admin/setup-config.php?step=1

    Despite the error the installer seems to work fine and WordPress seems to be installed correctly, at least on the first glance.

    However, since an error was logged during installation I’m worried that I can’t be sure that no subtle, hard to find problems linger that may cause trouble later.

    Therefore I would like to ask if this error is safe to ignore or if it’s not then how to resolve it and how to install WordPress without it appearing?

    The exact steps I did:

    1. sudo apt install apache2 php-fpm php-mysql mariadb-client mariadb-server php-curl php-mbstring php-imagick php-zip php-xml
    2. sudo mariadb, and then:
      
      MariaDB [(none)]> CREATE DATABASE wordpress;
      Query OK, 1 row affected (0.000 sec)
      
      MariaDB [(none)]> GRANT ALL PRIVILEGES ON wordpress.* TO "wordpressusername"@"localhost" IDENTIFIED BY "redacted";
      Query OK, 0 rows affected (0.002 sec)
      
      MariaDB [(none)]> FLUSH PRIVILEGES;
      Query OK, 0 rows affected (0.000 sec)
      
    3. wget https://wordpress.org/latest.tar.gz
      tar -xzvf latest.tar.gz
      sudo cp -R wordpress /var/www/
      sudo chown -R www-data:www-data /var/www/wordpress/
    4. Inside /etc/apache2/sites-available create file wordpress.conf with content:
      
      <VirtualHost 127.0.0.1:80>
      
      	DocumentRoot /var/www/wordpress
      	ServerName localhost
      
      	<Directory "/var/www/wordpress">
      		Require all granted
      		AllowOverride FileInfo
      	</Directory>
      
      	ErrorLog ${APACHE_LOG_DIR}/error.log
      	CustomLog ${APACHE_LOG_DIR}/access.log combined
      
      </VirtualHost>
      
    5. sudo a2enmod proxy_fcgi setenvif rewrite
      sudo a2enconf php7.4-fpm
      sudo a2ensite wordpress
      sudo systemctl restart apache2

    6. Enter http://localhost/ in the browser, click through the installation script, when asked for database details enter the following:

      Database Name: wordpress
      Username: wordpressusername
      Password: redacted
      Database Host: localhost
      Table Prefix: wp_

    EDIT: I’m very sorry that when I posted this question it was a formatting mess 🙁 I hope I managed to fix this

    • This topic was modified 1 month, 1 week ago by kmph.
    • This topic was modified 1 month, 1 week ago by kmph.
    • This topic was modified 1 month, 1 week ago by kmph.
    • This topic was modified 1 month, 1 week ago by kmph.
    • This topic was modified 1 month, 1 week ago by kmph.
    • This topic was modified 1 month, 1 week ago by kmph.
    • This topic was modified 1 month, 1 week ago by kmph.
    • This topic was modified 1 month, 1 week ago by kmph.
    • This topic was modified 1 month, 1 week ago by kmph.
    • This topic was modified 1 month, 1 week ago by kmph.
    • This topic was modified 1 month, 1 week ago by kmph.
    • This topic was modified 1 month, 1 week ago by kmph.
    • This topic was modified 1 month, 1 week ago by kmph.
    • This topic was modified 1 month, 1 week ago by kmph.
    • This topic was modified 1 month, 1 week ago by kmph.
    • This topic was modified 1 month, 1 week ago by kmph.
    • This topic was modified 1 month, 1 week ago by kmph.
    • This topic was modified 1 month, 1 week ago by kmph.
    • This topic was modified 1 month, 1 week ago by kmph.
    • This topic was modified 1 month, 1 week ago by kmph.
    • This topic was modified 1 month, 1 week ago by kmph.
    • This topic was modified 1 month, 1 week ago by kmph.
    • This topic was modified 1 month, 1 week ago by kmph.
    • This topic was modified 1 month, 1 week ago by kmph.
    • This topic was modified 1 month, 1 week ago by kmph.
    • This topic was modified 1 month, 1 week ago by kmph.
    • This topic was modified 1 month, 1 week ago by kmph.
    • This topic was modified 1 month, 1 week ago by kmph.
Viewing 4 replies - 1 through 4 (of 4 total)
  • Make sure the database user has the right permissions. Run the Health Check plugin to see if there’s a problem with your site. Check if the DB resolves correctly.

    Thread Starter kmph

    (@kmph)

    Make sure the database user has the right permissions.

    Well I did this: GRANT ALL PRIVILEGES ON wordpress.* TO "wordpressusername"@"localhost" IDENTIFIED BY "redacted"; Not sure if there are any other perms the database user should, or even could be given?

    Run the Health Check plugin to see if there’s a problem with your site.

    Thank you for pointing me to this plugin, I didn’t know about it, I thought that the default Tools -> Site health page did all self checks WordPress could do.

    It complains about two things the default Site health tool did not complain: namely that I use a non-localized timezone (but I can only fix this after installation, so I guess this can’t be the reason for errors during installation) and that I miss the bcmath PHP module.

    I did sudo apt install php-bcmath, removed the current WordPress installation, removed the database, copied WordPress to /var/www/wordpress again, set up the database again and run opened setup-config.php in the browser once again. Sadly the same error again appeared in /var/log/apache2/error.log at the same time (when I submited database connection data).

    Check if the DB resolves correctly.

    I believe it has to, since I can add a post and it seems to be saved? It appears when I do SELECT * FROM wordpress.wp_posts in the console mariadb cliect

    • This reply was modified 1 month, 1 week ago by kmph.

    Not sure if there are any other perms the database user should, or even could be given?

    No, that should be enough.

    removed the current WordPress installation, removed the database, copied WordPress again, set up the database again and run opened setup-config.php in the browser once again. Sadly the same error again appeared in /error.log

    It seems like you are not alone with this issue:

    https://wordpress.org/support/topic/database-error-unknowon-column-wp_-in-field-list-for-query-select-wp_/

    https://wordpress.stackexchange.com/questions/380631/wp-5-6-install-message-unknown-column-wp-in-field-list-for-query-select-w

    This thread has a possible solution:
    https://stackoverflow.com/questions/61664341/wp-database-error-unknowon-column-wp-in-field-list-for-query-select-wp

    Thread Starter kmph

    (@kmph)

    Thank you for the links.

    `Finally found the issue…

    TLDR; edit your php.ini and make sure you have both:

    display_errors = On

    error_log = php_errors.log

    Setting error_log solves the issue… I guess that when error_log has no value (default configuration), PHP decides to send the error back to the calling program, resulting in the error message column ‘wp_’ in ‘field list’ during the WP installation.`

    But in my case the error is not shown in the browser, rather it is shown in the logs. Errors appearing in the logs worried me. If I understand correctly this answer explains how to send this error to a log file and prevent it from being shown in the browser.

    I think I did find a way to stop this error from appearing in the logs – just edit wp-config myself…

Viewing 4 replies - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.