{"id":7499,"date":"2026-04-08T09:28:52","date_gmt":"2026-04-08T07:28:52","guid":{"rendered":"https:\/\/mybox.com\/help\/?post_type=manual_kb&#038;p=7499"},"modified":"2026-04-08T09:28:54","modified_gmt":"2026-04-08T07:28:54","slug":"how-to-fix-the-error-establishing-a-database-connection-in-wordpress","status":"publish","type":"manual_kb","link":"https:\/\/mybox.com\/help\/en\/knowledgebase\/how-to-fix-the-error-establishing-a-database-connection-in-wordpress\/","title":{"rendered":"How to fix the &#8220;Error Establishing a Database Connection&#8221; in WordPress"},"content":{"rendered":"\n<div class=\"translation-block translation-block-merged\">\n<p class=\"wp-block-paragraph\">When your WordPress site displays this error, it means the PHP code is unable to link up with the MySQL database where your posts, pages, and settings are stored. On the <strong>mybox<\/strong> infrastructure, this is almost always due to a mismatch in the login credentials stored in your configuration file.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">This typically happens after a database password has been reset in the dashboard or if the <code>wp-config.php<\/code> file was edited incorrectly.<\/p>\n\n\n\n<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_86 ez-toc-wrap-left counter-hierarchy ez-toc-counter ez-toc-custom ez-toc-container-direction\">\n<div class=\"ez-toc-title-container\">\n<p class=\"ez-toc-title\" style=\"cursor:inherit\">Table of Contents<\/p>\n<span class=\"ez-toc-title-toggle\"><\/span><\/div>\n<nav><ul class='ez-toc-list ez-toc-list-level-1 ' ><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/mybox.com\/help\/en\/knowledgebase\/how-to-fix-the-error-establishing-a-database-connection-in-wordpress\/#Locating_your_Database_Credentials\" >Locating your Database Credentials<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/mybox.com\/help\/en\/knowledgebase\/how-to-fix-the-error-establishing-a-database-connection-in-wordpress\/#How_to_Reset_and_Sync_the_Password\" >How to Reset and Sync the Password<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/mybox.com\/help\/en\/knowledgebase\/how-to-fix-the-error-establishing-a-database-connection-in-wordpress\/#Distinction_Block\" >Distinction Block<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-4\" href=\"https:\/\/mybox.com\/help\/en\/knowledgebase\/how-to-fix-the-error-establishing-a-database-connection-in-wordpress\/#Practical_Implications\" >Practical Implications<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-5\" href=\"https:\/\/mybox.com\/help\/en\/knowledgebase\/how-to-fix-the-error-establishing-a-database-connection-in-wordpress\/#Summary\" >Summary<\/a><\/li><\/ul><\/nav><\/div>\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Locating_your_Database_Credentials\"><\/span>Locating your Database Credentials<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<\/div>\n\n<div id=\"mybox-3221469431\" class=\"mybox-content mybox-entity-placement\"><div class=\"early-access-banner-inpost\">\r\n  <div class=\"banner-left-inpost\">\r\n    <div class=\"icon-box-inpost\">\r\n      <img decoding=\"async\" src=\"https:\/\/mybox.com\/help\/wp-content\/uploads\/2026\/02\/square-info-icon.svg\" alt=\"Info\">\r\n    <\/div>\r\n    <div class=\"text-box-inpost\">\r\n      <span class=\"label-inpost\"><span class=\"translation-block translation-block-banner-text\">Early access<\/span><\/span>\r\n      <h4><span class=\"translation-block translation-block-banner-text\">Still need help?<\/span><\/h4>\r\n      <p><span class=\"translation-block translation-block-banner-text\">Contact our customer service team.<\/span><\/p>\r\n    <\/div>\r\n  <\/div>\r\n\r\n  <div class=\"banner-right-inpost\">\r\n    <a href=\"https:\/\/panel.mybox.com\/helpdesk2\/v\/list\/\" class=\"banner-button-inpost\"><span class=\"translation-block translation-block-banner-text\">Message us<\/span><\/a>\r\n  <\/div>\r\n<\/div><\/div>\n\n<div class=\"translation-block translation-block-merged\"><p class=\"wp-block-paragraph\">To fix the connection, you must compare the data in your website&#8217;s configuration file with the actual settings in your <strong>mybox<\/strong> panel.<\/p>\n\n\n\n<ol start=\"1\" class=\"wp-block-list\">\n<li>Connect to your server via <strong>FTP<\/strong> or <strong>SFTP<\/strong>.<\/li>\n\n\n\n<li>Navigate to your website&#8217;s root directory (usually <code>public_html<\/code>).<\/li>\n\n\n\n<li>Open the <code>wp-config.php<\/code> file and look for these three lines:<\/li>\n<\/ol>\n\n\n\n<p class=\"wp-block-paragraph\">PHP<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>define('DB_NAME', 'database_name');     \/\/ The name of the database\ndefine('DB_USER', 'database_user');     \/\/ Your MySQL username\ndefine('DB_PASSWORD', 'your_password'); \/\/ Your MySQL password\n<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"How_to_Reset_and_Sync_the_Password\"><\/span>How to Reset and Sync the Password<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">If you are unsure what the correct password is, the most reliable fix is to set a new one in the <strong>mybox<\/strong> panel and then update the file.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>1. Set a new password in the panel<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Log in to your <strong>mybox<\/strong> dashboard and go to <strong>Databases<\/strong> > <strong>MySQL Users<\/strong>.<\/li>\n\n\n\n<li>Find the user listed in your <code>wp-config.php<\/code> file (the <code>DB_USER<\/code> value).<\/li>\n\n\n\n<li>Click <strong>Change password<\/strong>.<\/li>\n\n\n\n<li>Enter a new password or use the generator, then save the changes.<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>2. Update the configuration file<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Go back to your <code>wp-config.php<\/code> file in your text editor.<\/li>\n\n\n\n<li>Replace the old value in <code>DB_PASSWORD<\/code> with the exact password you just created in the panel.<\/li>\n\n\n\n<li>Save the file and upload it back to the server.<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Distinction_Block\"><\/span>Distinction Block<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p class=\"wp-block-paragraph\"><strong>Database User vs. Panel User<\/strong> Your <strong>mybox<\/strong> panel login is different from your <strong>MySQL User<\/strong> login. WordPress needs the specific MySQL credentials found in the &#8220;Databases&#8221; section to access your site data.<\/p>\n<\/blockquote>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Practical_Implications\"><\/span>Practical Implications<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>White Screen vs. Error Message:<\/strong> If you see a completely blank screen instead of the database error message, you may also need to enable <code>WP_DEBUG<\/code> to see if there are additional PHP errors.<\/li>\n\n\n\n<li><strong>Database Host:<\/strong> In the <code>wp-config.php<\/code> file, there is also a <code>DB_HOST<\/code> line. On the <strong>mybox<\/strong> infrastructure, this is usually set to <code>localhost<\/code>. Do not change this unless specifically instructed by support.<\/li>\n\n\n\n<li><strong>Table Prefix:<\/strong> If you have recently migrated your site and the connection is successful but the site looks &#8220;empty,&#8221; check the <code>$table_prefix<\/code> line in <code>wp-config.php<\/code>. It must match the prefix used by the tables in your database (e.g., <code>wp_<\/code>).<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Summary\"><\/span>Summary<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">The &#8220;Error Establishing a Database Connection&#8221; is a simple &#8220;wrong key&#8221; problem. By verifying the database name, username, and password in your <strong>mybox<\/strong> panel and ensuring they match your <code>wp-config.php<\/code> file exactly, you can restore your website to full functionality.<\/p>\n<\/div>\n","protected":false},"author":1,"featured_media":0,"parent":0,"menu_order":0,"template":"","format":"standard","manualknowledgebasecat":[25,43,58],"manual_kb_tag":[],"class_list":["post-7499","manual_kb","type-manual_kb","status-publish","format-standard","hentry","manualknowledgebasecat-hosting","manualknowledgebasecat-website-errors","manualknowledgebasecat-web-applications-cms"],"_links":{"self":[{"href":"https:\/\/mybox.com\/help\/en\/wp-json\/wp\/v2\/manual_kb\/7499","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/mybox.com\/help\/en\/wp-json\/wp\/v2\/manual_kb"}],"about":[{"href":"https:\/\/mybox.com\/help\/en\/wp-json\/wp\/v2\/types\/manual_kb"}],"author":[{"embeddable":true,"href":"https:\/\/mybox.com\/help\/en\/wp-json\/wp\/v2\/users\/1"}],"version-history":[{"count":1,"href":"https:\/\/mybox.com\/help\/en\/wp-json\/wp\/v2\/manual_kb\/7499\/revisions"}],"predecessor-version":[{"id":7500,"href":"https:\/\/mybox.com\/help\/en\/wp-json\/wp\/v2\/manual_kb\/7499\/revisions\/7500"}],"wp:attachment":[{"href":"https:\/\/mybox.com\/help\/en\/wp-json\/wp\/v2\/media?parent=7499"}],"wp:term":[{"taxonomy":"manualknowledgebasecat","embeddable":true,"href":"https:\/\/mybox.com\/help\/en\/wp-json\/wp\/v2\/manualknowledgebasecat?post=7499"},{"taxonomy":"manual_kb_tag","embeddable":true,"href":"https:\/\/mybox.com\/help\/en\/wp-json\/wp\/v2\/manual_kb_tag?post=7499"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}