Problem: Moving a WordPress Site

Error Establishing Database ConnectionWhen you have to change the name servers to move a WordPress site to another host, many thing can go wrong, but since it’s WordPress there is always a way to fix it. One of the crucial things when moving a site to another domain name, e.g. from a subdomain to a primary domain, is the permalink structure of the website. Once you built your new site on a subdomain and everything looks fine and you’re ready to move the domain to the new site you may be faced with this error message when trying to log in to your WordPress admin as soon as you changed the url on the WordPress settings page. This is because WordPress caches the rewrite rules until something changes in the site that would effect the permalink structure to be rebuilt. The cached rewrite rules will prevent you from logging in to WP admin wit a different domain as it has been built in and you won’t be able to update the permalink structure in Settings -> Permalinks.

Solution: Update the Permalink Structure in PhPMyAdmin

To solve the problem you’ll have to access the WordPress database via PhpMyAdmin over your web hosting account. Once you’re logged in and see your database tables, click to open the wp-options table in the left column and do a search for theoption  key “rewrite_rules”.  Now click on edit and delete the whole gibberish content you will find in there. This is the entry of your permalink structure. No worries, nothing bad will happen to your new website when you delete the content! Once the field is empty and the option is saved, try to open your wp-admin section again. This might require you to empty your browser cache and relod the page with ctrl+F5, but will result in a new permalink structure being built automatically by WordPress, thus you successfully updated the permalink structure without access to your WordPress back-end.