Title: Error establishing a database connection
Last modified: August 21, 2016

---

# Error establishing a database connection

 *  [angeloluidens](https://wordpress.org/support/users/angeloluidens/)
 * (@angeloluidens)
 * [12 years, 4 months ago](https://wordpress.org/support/topic/error-establishing-a-database-connection-550/)
 * I have an installation of WP3.8 hosted online that I have made a copy of and 
   installed locally, to continue working on it offline and to be uploaded and update
   the online version once completed.
 * Upon accessing the site I get the infamous: Error establishing a database connection.
 * I have tried the following:
    Checked the parameters in wp-config.php – These 
   correct. Modified the urls “siteurl” and “home” fields in the wp_options table
   in the WP database. – These are correct. Modified .htaccess in the localhost/
   wordpress folder and modified the RewriteBase /wordpress statement. Checked the
   above several times for possible spelling errors. Checked the connection to the
   database is working by using a testconnection.php script. The script works and
   reports successful connection. This also confirms that the dbhost, dbuser, and
   dbpassword are correct. Checked the MySQL server is working – confirmed Checked
   MySQL error log – no errors Checked the Appache server is working – confirmed
   Checked Appache error log – no errors Checked PHP error log – no errors Checked
   the database using phpMyAdmin – confirmed and Repaired Tried to repair the database
   with the repair.php script in localhost/wordpress/wp-admin/maint – the script
   reports the database connection error Tried to access the localhost/wordpress/
   wp-admin – it reports the following:
 * Error establishing a database connection
    If your site does not display, please
   contact the owner of this network. If you are the owner of this network please
   check that MySQL is running properly and all tables are error free.
 * Could not find site localhost/wordpress. Searched for table wp_blogs in database
   wpdb. Is that right?
 * What do I do now? Read the bug report page. Some of the guidelines there may 
   help you figure out what went wrong. If you’re still stuck with this message,
   then check that your database contains the following tables:
 * wp_users
    wp_usermeta wp_blogs wp_signups wp_site wp_sitemeta wp_registration_log
   wp_blog_versions
 * Verified if wp_blog exists – confirmed.
    Checked the bug report page Other lessor
   known issues: Checked root (MySQL user) has all privileges to the wp database–
   confirmed
 * I would greatly appreciate any assistance in resolving this. Thank you in advance.

Viewing 2 replies - 1 through 2 (of 2 total)

 *  [2ninerniner2](https://wordpress.org/support/users/2ninerniner2/)
 * (@2ninerniner2)
 * [12 years, 4 months ago](https://wordpress.org/support/topic/error-establishing-a-database-connection-550/#post-4453486)
 * What are you using for a local server? XAMPP, MAMP (Mac), etc.
 * This is the way I usually do this:
 * Live site:
    – export the database and download the .sql file – ZIP the entire
   contents of the site and download
 * Local site:
    – create new, empty database – import the exported .sql file into
   it – edit the siteurl and home fields in wp_options table with the local site
   URL – create a new folder in the root of the local server and unZIP the site 
   there – edit wp-config.php in the local site for the local database credentials–
   run this script to change the URLs of links, media, etc. to the local URL:
 * `http://interconnectit.com/products/search-and-replace-for-wordpress-databases/`
 * Note: this scrip handles URLs that are stored in the database as serialized strings;
   the Velvet Blues Update URLs does not handle these.
 * – log in to local site, install and run this plugin:
 * ‘[http://wordpress.org/plugins/velvet-blues-update-urls/](http://wordpress.org/plugins/velvet-blues-update-urls/)`
 * Note: I have found occasions where the search and replace script did not catch
   all items; running this one completed the task.
 * That’s it. Sounds like a lot but generally takes me about 5 minutes.
 *  [2ninerniner2](https://wordpress.org/support/users/2ninerniner2/)
 * (@2ninerniner2)
 * [12 years, 4 months ago](https://wordpress.org/support/topic/error-establishing-a-database-connection-550/#post-4453487)
 * One more thing … go to Permalinks and just re-save.

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Error establishing a database connection’ is closed to new replies.

## Tags

 * [Error establishing a database connection](https://wordpress.org/support/topic-tag/error-establishing-a-database-connection/)
 * [Windows 8.1](https://wordpress.org/support/topic-tag/windows-8-1/)
 * [WordPress 3.8.1](https://wordpress.org/support/topic-tag/wordpress-3-8-1/)

 * In: [Localhost Installs](https://wordpress.org/support/forum/localhost-installs/)
 * 2 replies
 * 2 participants
 * Last reply from: [2ninerniner2](https://wordpress.org/support/users/2ninerniner2/)
 * Last activity: [12 years, 4 months ago](https://wordpress.org/support/topic/error-establishing-a-database-connection-550/#post-4453487)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
