{"id":9188,"date":"2017-11-08T15:13:18","date_gmt":"2017-11-08T20:13:18","guid":{"rendered":"https:\/\/www.boldgrid.com\/support\/?p=9188"},"modified":"2020-03-12T14:39:23","modified_gmt":"2020-03-12T18:39:23","slug":"troubleshooting-error-establishing-database-connection","status":"publish","type":"post","link":"https:\/\/www.boldgrid.com\/support\/troubleshooting\/troubleshooting-error-establishing-database-connection\/","title":{"rendered":"Troubleshooting &#8220;Error Establishing Database Connection&#8221;"},"content":{"rendered":"<!DOCTYPE html PUBLIC \"-\/\/W3C\/\/DTD HTML 4.0 Transitional\/\/EN\" \"http:\/\/www.w3.org\/TR\/REC-html40\/loose.dtd\">\n<?xml encoding=\"utf-8\" ?><html><body><p>Getting the <strong>&ldquo;Error Establishing Database Connection&rdquo;<\/strong> page can be a frustrating experience. In most cases, this means your website files are not able to connect to the MySQL service, or the service is not running. The following article will explain how you can troubleshoot these types of <b>MySQL<\/b> issues.<\/p>\n<p>&nbsp;<\/p>\n<p><a href=\"https:\/\/www.boldgrid.com\/support\/wp-content\/uploads\/2017\/08\/9188-01-db-error.jpg\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.boldgrid.com\/support\/wp-content\/uploads\/2017\/08\/9188-01-db-error.jpg\" alt=\"\" width=\"935\" height=\"564\" class=\"aligncenter size-full wp-image-9190\"><\/a><br>\nThere are three common reasons that can cause the message &ldquo;Error Establishing Database Connection&rdquo; to occur on your website. <\/p>\n<ol>\n<li>The login credentials in the configuration are not correct, <\/li>\n<li>the MySQL server is not running, or <\/li>\n<li>he database is corrupted, and in need of repair. <\/li>\n<\/ol>\n<p>The following article will outline instructions on checking all three.<\/p>\n<h2 id=\"checking-the-mysql-login-credentials\">Checking the MySQL login credentials<\/h2>\n<p>If you have recently made any changes to the configuration, or installed WordPress, you can check the wp-config.php file to ensure the credentials match what MySQL expects. The credentials you would need to accomplish this are the host, the database username, the database users password, and the database name itself. <\/p>\n<div class=\"alert alert-info\">If you are not familiar with editing your files, then it would be recommended to contact your host, as they should have the information needed to help you with this step.<\/div>\n<p><a href=\"https:\/\/www.boldgrid.com\/support\/wp-content\/uploads\/2017\/08\/9188-02-wp-config.jpg\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.boldgrid.com\/support\/wp-content\/uploads\/2017\/08\/9188-02-wp-config.jpg\" alt=\"\" width=\"1117\" height=\"817\" class=\"aligncenter size-full wp-image-9191\" srcset=\"https:\/\/www.boldgrid.com\/support\/wp-content\/uploads\/2017\/08\/9188-02-wp-config.jpg 1117w, https:\/\/www.boldgrid.com\/support\/wp-content\/uploads\/2017\/08\/9188-02-wp-config-300x219.jpg 300w, https:\/\/www.boldgrid.com\/support\/wp-content\/uploads\/2017\/08\/9188-02-wp-config-768x562.jpg 768w, https:\/\/www.boldgrid.com\/support\/wp-content\/uploads\/2017\/08\/9188-02-wp-config-1024x749.jpg 1024w, https:\/\/www.boldgrid.com\/support\/wp-content\/uploads\/2017\/08\/9188-02-wp-config-250x183.jpg 250w, https:\/\/www.boldgrid.com\/support\/wp-content\/uploads\/2017\/08\/9188-02-wp-config-550x402.jpg 550w, https:\/\/www.boldgrid.com\/support\/wp-content\/uploads\/2017\/08\/9188-02-wp-config-800x585.jpg 800w, https:\/\/www.boldgrid.com\/support\/wp-content\/uploads\/2017\/08\/9188-02-wp-config-246x180.jpg 246w, https:\/\/www.boldgrid.com\/support\/wp-content\/uploads\/2017\/08\/9188-02-wp-config-410x300.jpg 410w, https:\/\/www.boldgrid.com\/support\/wp-content\/uploads\/2017\/08\/9188-02-wp-config-684x500.jpg 684w\" sizes=\"auto, (max-width: 1117px) 100vw, 1117px\" \/><\/a><br>\nIn this example, the credentials needed would be the following:<br>\nDatabase Name: database_name<br>\nDatabase Username: database_username<br>\nPassword: database_password<br>\nHost: localhost<\/p>\n<p>&nbsp;<br>\nThe easiest way to verify these credentials is to navigate to your hosts MySQL interface, and it should  list the database with the attached user, as well as have a place to set the password. If you are not able to view the current password, you would want to set it to what is found within your wp-config.php file, to ensure that the credentials match.<\/p>\n<h2 id=\"checking-the-mysql-server\">Checking the MySQL server<\/h2>\n<p>If you have checked your MySQL credentials, and the problem persists, there may be an issue with your MySQL server. To check the status, you can use telnet to view the status of the service. The simplest way to do so would be running the following command:<br>\n<code>telnet yourdomain.com 3306<\/code><br>\nIf MySQL is running, this should return output similar to the following:<br>\n<a href=\"https:\/\/www.boldgrid.com\/support\/wp-content\/uploads\/2017\/08\/9188-03-telnet.jpg\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.boldgrid.com\/support\/wp-content\/uploads\/2017\/08\/9188-03-telnet.jpg\" alt=\"\" width=\"938\" height=\"412\" class=\"aligncenter size-full wp-image-9192\" srcset=\"https:\/\/www.boldgrid.com\/support\/wp-content\/uploads\/2017\/08\/9188-03-telnet.jpg 938w, https:\/\/www.boldgrid.com\/support\/wp-content\/uploads\/2017\/08\/9188-03-telnet-300x132.jpg 300w, https:\/\/www.boldgrid.com\/support\/wp-content\/uploads\/2017\/08\/9188-03-telnet-768x337.jpg 768w, https:\/\/www.boldgrid.com\/support\/wp-content\/uploads\/2017\/08\/9188-03-telnet-250x110.jpg 250w, https:\/\/www.boldgrid.com\/support\/wp-content\/uploads\/2017\/08\/9188-03-telnet-550x242.jpg 550w, https:\/\/www.boldgrid.com\/support\/wp-content\/uploads\/2017\/08\/9188-03-telnet-800x351.jpg 800w, https:\/\/www.boldgrid.com\/support\/wp-content\/uploads\/2017\/08\/9188-03-telnet-410x180.jpg 410w, https:\/\/www.boldgrid.com\/support\/wp-content\/uploads\/2017\/08\/9188-03-telnet-683x300.jpg 683w\" sizes=\"auto, (max-width: 938px) 100vw, 938px\" \/><\/a><br>\nIf it is not running, the Connection will be refused<br>\ntelnet: connect to address IP ADDRESS: Connection refused<\/p>\n<h2 id=\"repairing-your-database\">Repairing your Database<\/h2>\n<p>The third most common reason for the &ldquo;Error Establishing a Database Connection&rdquo; is a corrupt database, which can be caused by a number of things. Some of the reasons include a server crash, or hardware failure as well as processed being killed while writing to the database. These crashes also depend whether you are using MyISAM or InnoDB, as MyISAM is more susceptible to corruption. <\/p>\n<p>&nbsp;<\/p>\n<p>To correct this, you can simply add this line to your wp-config.php file:<br>\n<code>define( 'WP_ALLOW_REPAIR', true );<\/code><br>\nOnce you have added this, you can reload your website, and should see this message when visiting \/wp-admin\/<br>\n<a href=\"https:\/\/www.boldgrid.com\/support\/wp-content\/uploads\/2017\/08\/9188-04-wp-admin-repair.jpg\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.boldgrid.com\/support\/wp-content\/uploads\/2017\/08\/9188-04-wp-admin-repair.jpg\" alt=\"\" width=\"973\" height=\"356\" class=\"aligncenter size-full wp-image-9193\" srcset=\"https:\/\/www.boldgrid.com\/support\/wp-content\/uploads\/2017\/08\/9188-04-wp-admin-repair.jpg 973w, https:\/\/www.boldgrid.com\/support\/wp-content\/uploads\/2017\/08\/9188-04-wp-admin-repair-300x110.jpg 300w, https:\/\/www.boldgrid.com\/support\/wp-content\/uploads\/2017\/08\/9188-04-wp-admin-repair-768x281.jpg 768w, https:\/\/www.boldgrid.com\/support\/wp-content\/uploads\/2017\/08\/9188-04-wp-admin-repair-250x91.jpg 250w, https:\/\/www.boldgrid.com\/support\/wp-content\/uploads\/2017\/08\/9188-04-wp-admin-repair-550x201.jpg 550w, https:\/\/www.boldgrid.com\/support\/wp-content\/uploads\/2017\/08\/9188-04-wp-admin-repair-800x293.jpg 800w, https:\/\/www.boldgrid.com\/support\/wp-content\/uploads\/2017\/08\/9188-04-wp-admin-repair-492x180.jpg 492w, https:\/\/www.boldgrid.com\/support\/wp-content\/uploads\/2017\/08\/9188-04-wp-admin-repair-820x300.jpg 820w\" sizes=\"auto, (max-width: 973px) 100vw, 973px\" \/><\/a><br>\nIf editing your files is not something you wish to do, the following guide will show you how to repair your database within phpMyAdmin.<\/p>\n<h2 id=\"repairing-a-database-in-phpmyadmin\">Repairing a database in phpMyAdmin<\/h2>\n<ol class=\"article-list\">\n<li>Login to phpMyAdmin\n<div style=\"clear: both;\"><\/div>\n<\/li>\n<li><a href=\"https:\/\/www.boldgrid.com\/support\/wp-content\/uploads\/2017\/08\/9188-05-phpmyadmin-1.jpg\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.boldgrid.com\/support\/wp-content\/uploads\/2017\/08\/9188-05-phpmyadmin-1-300x163.jpg\" alt=\"\" width=\"300\" height=\"163\" class=\"alignright size-medium wp-image-9200\" srcset=\"https:\/\/www.boldgrid.com\/support\/wp-content\/uploads\/2017\/08\/9188-05-phpmyadmin-1-300x163.jpg 300w, https:\/\/www.boldgrid.com\/support\/wp-content\/uploads\/2017\/08\/9188-05-phpmyadmin-1-768x418.jpg 768w, https:\/\/www.boldgrid.com\/support\/wp-content\/uploads\/2017\/08\/9188-05-phpmyadmin-1-250x136.jpg 250w, https:\/\/www.boldgrid.com\/support\/wp-content\/uploads\/2017\/08\/9188-05-phpmyadmin-1-550x299.jpg 550w, https:\/\/www.boldgrid.com\/support\/wp-content\/uploads\/2017\/08\/9188-05-phpmyadmin-1-800x435.jpg 800w, https:\/\/www.boldgrid.com\/support\/wp-content\/uploads\/2017\/08\/9188-05-phpmyadmin-1-331x180.jpg 331w, https:\/\/www.boldgrid.com\/support\/wp-content\/uploads\/2017\/08\/9188-05-phpmyadmin-1-552x300.jpg 552w, https:\/\/www.boldgrid.com\/support\/wp-content\/uploads\/2017\/08\/9188-05-phpmyadmin-1-920x500.jpg 920w, https:\/\/www.boldgrid.com\/support\/wp-content\/uploads\/2017\/08\/9188-05-phpmyadmin-1.jpg 973w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a>Choose the database you are working with by clicking on it in the left menu\n<div style=\"clear: both;\"><\/div>\n<\/li>\n<li><a href=\"https:\/\/www.boldgrid.com\/support\/wp-content\/uploads\/2017\/08\/9188-05-phpmyadmin-2.jpg\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.boldgrid.com\/support\/wp-content\/uploads\/2017\/08\/9188-05-phpmyadmin-2-300x163.jpg\" alt=\"\" width=\"300\" height=\"163\" class=\"alignright size-medium wp-image-9201\" srcset=\"https:\/\/www.boldgrid.com\/support\/wp-content\/uploads\/2017\/08\/9188-05-phpmyadmin-2-300x163.jpg 300w, https:\/\/www.boldgrid.com\/support\/wp-content\/uploads\/2017\/08\/9188-05-phpmyadmin-2-768x418.jpg 768w, https:\/\/www.boldgrid.com\/support\/wp-content\/uploads\/2017\/08\/9188-05-phpmyadmin-2-250x136.jpg 250w, https:\/\/www.boldgrid.com\/support\/wp-content\/uploads\/2017\/08\/9188-05-phpmyadmin-2-550x299.jpg 550w, https:\/\/www.boldgrid.com\/support\/wp-content\/uploads\/2017\/08\/9188-05-phpmyadmin-2-800x435.jpg 800w, https:\/\/www.boldgrid.com\/support\/wp-content\/uploads\/2017\/08\/9188-05-phpmyadmin-2-331x180.jpg 331w, https:\/\/www.boldgrid.com\/support\/wp-content\/uploads\/2017\/08\/9188-05-phpmyadmin-2-552x300.jpg 552w, https:\/\/www.boldgrid.com\/support\/wp-content\/uploads\/2017\/08\/9188-05-phpmyadmin-2-920x500.jpg 920w, https:\/\/www.boldgrid.com\/support\/wp-content\/uploads\/2017\/08\/9188-05-phpmyadmin-2.jpg 973w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a>Underneath the database, select Check All to highlight all the tables above\n<div style=\"clear: both;\"><\/div>\n<\/li>\n<li><a href=\"https:\/\/www.boldgrid.com\/support\/wp-content\/uploads\/2017\/08\/9188-05-phpmyadmin-3.jpg\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.boldgrid.com\/support\/wp-content\/uploads\/2017\/08\/9188-05-phpmyadmin-3-300x163.jpg\" alt=\"\" width=\"300\" height=\"163\" class=\"alignright size-medium wp-image-9202\" srcset=\"https:\/\/www.boldgrid.com\/support\/wp-content\/uploads\/2017\/08\/9188-05-phpmyadmin-3-300x163.jpg 300w, https:\/\/www.boldgrid.com\/support\/wp-content\/uploads\/2017\/08\/9188-05-phpmyadmin-3-768x418.jpg 768w, https:\/\/www.boldgrid.com\/support\/wp-content\/uploads\/2017\/08\/9188-05-phpmyadmin-3-250x136.jpg 250w, https:\/\/www.boldgrid.com\/support\/wp-content\/uploads\/2017\/08\/9188-05-phpmyadmin-3-550x299.jpg 550w, https:\/\/www.boldgrid.com\/support\/wp-content\/uploads\/2017\/08\/9188-05-phpmyadmin-3-800x435.jpg 800w, https:\/\/www.boldgrid.com\/support\/wp-content\/uploads\/2017\/08\/9188-05-phpmyadmin-3-331x180.jpg 331w, https:\/\/www.boldgrid.com\/support\/wp-content\/uploads\/2017\/08\/9188-05-phpmyadmin-3-552x300.jpg 552w, https:\/\/www.boldgrid.com\/support\/wp-content\/uploads\/2017\/08\/9188-05-phpmyadmin-3-920x500.jpg 920w, https:\/\/www.boldgrid.com\/support\/wp-content\/uploads\/2017\/08\/9188-05-phpmyadmin-3.jpg 973w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a>Using the menu on the right hand side of the Check All option, select Repair Table\n<div style=\"clear: both;\"><\/div>\n<\/li>\n<li><a href=\"https:\/\/www.boldgrid.com\/support\/wp-content\/uploads\/2017\/08\/9188-05-phpmyadmin-4.jpg\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.boldgrid.com\/support\/wp-content\/uploads\/2017\/08\/9188-05-phpmyadmin-4-300x163.jpg\" alt=\"\" width=\"300\" height=\"163\" class=\"alignright size-medium wp-image-9203\" srcset=\"https:\/\/www.boldgrid.com\/support\/wp-content\/uploads\/2017\/08\/9188-05-phpmyadmin-4-300x163.jpg 300w, https:\/\/www.boldgrid.com\/support\/wp-content\/uploads\/2017\/08\/9188-05-phpmyadmin-4-768x418.jpg 768w, https:\/\/www.boldgrid.com\/support\/wp-content\/uploads\/2017\/08\/9188-05-phpmyadmin-4-250x136.jpg 250w, https:\/\/www.boldgrid.com\/support\/wp-content\/uploads\/2017\/08\/9188-05-phpmyadmin-4-550x299.jpg 550w, https:\/\/www.boldgrid.com\/support\/wp-content\/uploads\/2017\/08\/9188-05-phpmyadmin-4-800x435.jpg 800w, https:\/\/www.boldgrid.com\/support\/wp-content\/uploads\/2017\/08\/9188-05-phpmyadmin-4-331x180.jpg 331w, https:\/\/www.boldgrid.com\/support\/wp-content\/uploads\/2017\/08\/9188-05-phpmyadmin-4-552x300.jpg 552w, https:\/\/www.boldgrid.com\/support\/wp-content\/uploads\/2017\/08\/9188-05-phpmyadmin-4-920x500.jpg 920w, https:\/\/www.boldgrid.com\/support\/wp-content\/uploads\/2017\/08\/9188-05-phpmyadmin-4.jpg 973w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a>Upon completion, you will see the Success Message\n<div style=\"clear: both;\"><\/div>\n<\/li>\n<\/ol>\n<p>&nbsp;<\/p>\n<p>Congratulations! Now you are familiar with troubleshooting the most common causes of the <strong>&ldquo;Error Establishing Database Connection&rdquo;<\/strong> message. If you are still receiving the error after attempting these steps, then it would be recommended to contact your host for further assistance.<\/p>\n<\/body><\/html>\n","protected":false},"excerpt":{"rendered":"<p>Getting the &ldquo;Error Establishing Database Connection&rdquo; page can be a frustrating experience. In most cases, this means your website files are not able to connect to the MySQL service, or the service is not running. The following article will explain how you can troubleshoot these types of MySQL issues. &nbsp; There are three common reasons [&hellip;]<\/p>\n","protected":false},"author":529,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"_bbp_topic_count":0,"_bbp_reply_count":0,"_bbp_total_topic_count":0,"_bbp_total_reply_count":0,"_bbp_voice_count":0,"_bbp_anonymous_reply_count":0,"_bbp_topic_count_hidden":0,"_bbp_reply_count_hidden":0,"_bbp_forum_subforum_count":0,"bgseo_title":"Troubleshooting \"Error Establishing Database Connection\"","bgseo_description":"The following article explains how you can troubleshoot MySQL issues such as \"Error Establishing Database Connection\" with BoldGrid, phpMyAdmin and telnet. ","bgseo_robots_index":"index","bgseo_robots_follow":"follow","footnotes":""},"categories":[74],"tags":[],"class_list":["post-9188","post","type-post","status-publish","format-standard","hentry","category-troubleshooting"],"acf":[],"_links":{"self":[{"href":"https:\/\/www.boldgrid.com\/support\/wp-json\/wp\/v2\/posts\/9188","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.boldgrid.com\/support\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.boldgrid.com\/support\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.boldgrid.com\/support\/wp-json\/wp\/v2\/users\/529"}],"replies":[{"embeddable":true,"href":"https:\/\/www.boldgrid.com\/support\/wp-json\/wp\/v2\/comments?post=9188"}],"version-history":[{"count":13,"href":"https:\/\/www.boldgrid.com\/support\/wp-json\/wp\/v2\/posts\/9188\/revisions"}],"predecessor-version":[{"id":9704,"href":"https:\/\/www.boldgrid.com\/support\/wp-json\/wp\/v2\/posts\/9188\/revisions\/9704"}],"wp:attachment":[{"href":"https:\/\/www.boldgrid.com\/support\/wp-json\/wp\/v2\/media?parent=9188"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.boldgrid.com\/support\/wp-json\/wp\/v2\/categories?post=9188"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.boldgrid.com\/support\/wp-json\/wp\/v2\/tags?post=9188"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}