Wordpress: Database access error of doom

wp-db-error Usually it happens after migration. When there is absolutely nothing that could possibly go wrong:

  • You already moved all the content to the new server and adjusted the permissions
  • You exported the database dump and imported it into the new database
  • You verified username, password for the database and checked again wp-config.php for errors
  • You even wrote a little test script to make sure

    and it works just fine

  • You turned on all PHP display_error and WP_DEBUG and still got nothing explaining the problem. In fact you got no error messages at all.

But still you are getting this ugly error as on picture above. And nothing in the logs that could shed any light on the situation even though you have all possible debug messages turned on. There is absolutely no indication what could be wrong but you almost sure that it’s not related to the database in this case. The only strange details is that you have HTTP error code 500 along with additional error message.
As the measure of last resort you are looking into the database dump, trying to find any trace for the problem. In the table wp_options, there is the very first record with option_name siteurl. And it so happens that it points to the wrong URL.

Rrrright. You were just moving your Wordpress site from DEV location to production, and your database dump contains DEV siteurl. Bingo! – that is exactly the reason for this cryptic error. All you need is manually edit SQL dump with your favorite text editor replacing old URL (which is located in siteurl record) with your current actual URL and import modified SQL dump again.
Ta-da! Your Wordpress site is now loading and it’s time to go disable WP_DEBUG in wp-config.php and display_errors in php.ini

Leave a Comment

NOTE - You can use these HTML tags and attributes:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">