{"id":20685,"date":"2020-11-30T05:00:52","date_gmt":"2020-11-29T21:00:52","guid":{"rendered":"https:\/\/web.mwwsb.com.my\/pjci\/?post_type=kb&#038;p=20685"},"modified":"2022-09-08T21:25:08","modified_gmt":"2022-09-08T13:25:08","slug":"how-to-fix-the-error-establishing-a-database-connection-in-wordpress","status":"publish","type":"kb","link":"https:\/\/www.casbay.com\/guide\/kb\/how-to-fix-the-error-establishing-a-database-connection-in-wordpress","title":{"rendered":"HOW TO:Fix the \u201cError Establishing a Database Connection\u201d in WordPress"},"content":{"rendered":"\t\t<div data-elementor-type=\"wp-post\" data-elementor-id=\"20685\" class=\"elementor elementor-20685\" data-elementor-post-type=\"kb\">\n\t\t\t\t\t\t\t\t\t<section class=\"elementor-section elementor-top-section elementor-element elementor-element-56588fa elementor-section-boxed elementor-section-height-default elementor-section-height-default\" data-id=\"56588fa\" data-element_type=\"section\">\n\t\t\t\t\t\t<div class=\"elementor-container elementor-column-gap-default\">\n\t\t\t\t\t<div class=\"elementor-column elementor-col-100 elementor-top-column elementor-element elementor-element-9844a92\" data-id=\"9844a92\" data-element_type=\"column\">\n\t\t\t<div class=\"elementor-widget-wrap elementor-element-populated\">\n\t\t\t\t\t\t\t\t<div class=\"elementor-element elementor-element-124641d elementor-widget elementor-widget-heading\" data-id=\"124641d\" data-element_type=\"widget\" data-widget_type=\"heading.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t<h2 class=\"elementor-heading-title elementor-size-default\">Fix the \u201cError Establishing a Database Connection\u201d in WordPress<\/h2>\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-45f0870 elementor-widget elementor-widget-text-editor\" data-id=\"45f0870\" data-element_type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t<p>As a dynamic content management system, WordPress relies on a MySQL database that stores your content, website settings, and more. If WordPress is unable to communicate with its database, you\u2019ll see an error message stating: <strong>Error establishing a database connection<\/strong>.<\/p>\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-fc0a8ef elementor-widget elementor-widget-image\" data-id=\"fc0a8ef\" data-element_type=\"widget\" data-widget_type=\"image.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<img decoding=\"async\" src=\"https:\/\/casbay.com\/guide\/wp-content\/uploads\/2021\/02\/wordpress12.png\" title=\"\" alt=\"\" loading=\"lazy\" \/>\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-16c4543 elementor-widget elementor-widget-text-editor\" data-id=\"16c4543\" data-element_type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t<figure id=\"attachment_6084\" class=\"wp-caption alignnone\" aria-describedby=\"caption-attachment-6084\"><figcaption id=\"caption-attachment-6084\" class=\"wp-caption-text\">Error establishing a database connection message<\/figcaption><\/figure>\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-9c51172 elementor-widget elementor-widget-text-editor\" data-id=\"9c51172\" data-element_type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t<p>If your WordPress website was previously working normally, clearly something has changed to break the link between WordPress and the database. Possible causes could be:<\/p><ul><li>The database server is down.<\/li><li>A change has been made to the database credentials (hostname, username or password) in your wp-config.php file.<\/li><\/ul><p>If this is the first time you\u2019ve tried to use WordPress, the most likely cause is that your database credentials are incorrect or have changed. Use the following steps to troubleshoot the issue.<\/p>\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-0f2cc32 elementor-widget elementor-widget-heading\" data-id=\"0f2cc32\" data-element_type=\"widget\" data-widget_type=\"heading.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t<h2 class=\"elementor-heading-title elementor-size-default\">Check your WordPress configuration<\/h2>\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-7394af9 elementor-widget elementor-widget-text-editor\" data-id=\"7394af9\" data-element_type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t<p>When installing WordPress, you will have been asked to input a\u00a0<strong>database hostname<\/strong>,\u00a0<strong>database name<\/strong>,\u00a0<strong>database username<\/strong>\u00a0and\u00a0<strong>password<\/strong>. These credentials are stored in your\u00a0<strong>wp-config.php<\/strong>\u00a0file. A great first step for troubleshooting database connection errors is to check that the database credentials in your wp-config.php file are correct.<\/p><p>You can use an\u00a0<strong>FTP client<\/strong>\u00a0to access the file on your hosting, or alternatively, use<strong>\u00a0cPanel File Manager<\/strong>.<\/p><p>Firstly, log in to your<strong>\u00a0cPanel<\/strong>.<\/p><p>Secondly, select\u00a0<strong>File Manager<\/strong>.<\/p><p>Then, Navigate to your WordPress folder and look for your\u00a0<strong>wp-config.php<\/strong>\u00a0file. Right click on the file and select\u00a0<strong>Edit<\/strong>.<\/p>\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-b8ef5da elementor-widget elementor-widget-image\" data-id=\"b8ef5da\" data-element_type=\"widget\" data-widget_type=\"image.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<img decoding=\"async\" src=\"https:\/\/casbay.com\/guide\/wp-content\/uploads\/2021\/02\/wordpress13.png\" title=\"\" alt=\"\" loading=\"lazy\" \/>\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-f068b51 elementor-widget elementor-widget-text-editor\" data-id=\"f068b51\" data-element_type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t<figure id=\"attachment_6084\" class=\"wp-caption alignnone\" aria-describedby=\"caption-attachment-6084\"><figcaption id=\"caption-attachment-6084\" class=\"wp-caption-text\">Navigate to WordPress folder<\/figcaption><\/figure>\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-82ddfab elementor-widget elementor-widget-text-editor\" data-id=\"82ddfab\" data-element_type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t<p>You\u2019ll see your database credentials listed under\u00a0<strong>MySQL settings<\/strong>. Check that the\u00a0<strong>database hostname<\/strong>,\u00a0<strong>database name<\/strong>,\u00a0<strong>database username, <\/strong>and\u00a0<strong>password<\/strong>\u00a0are correct. You can find your database credentials at\u00a0<strong>My cPanel &gt; MySQL Databases<\/strong>.<\/p><p>Make any necessary changes in your wp-config.php file and then click\u00a0<strong>Save Changes<\/strong>\u00a0to proceed. Try to access WordPress once again to see if your issue remains.<\/p>\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/div>\n\t\t\t\t\t\t\t<\/div>\n\t\t<\/section>\n\t\t\t\t\t\t\t<\/div>\n\t\t","protected":false},"excerpt":{"rendered":"<p>Fix the \u201cError Establishing a Database Connection\u201d in WordPress As a dynamic content management system, WordPress relies on a MySQL database that stores your content, website settings and more. If WordPress is unable to communicate with its database, you\u2019ll see an error message stating:\u00a0Error establishing a database connection. Error establishing a database connection message If [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"site-sidebar-layout":"no-sidebar","site-content-layout":"page-builder","ast-site-content-layout":"","site-content-style":"default","site-sidebar-style":"default","ast-global-header-display":"","ast-banner-title-visibility":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"disabled","ast-breadcrumbs-content":"","ast-featured-img":"disabled","footer-sml-layout":"","theme-transparent-header-meta":"default","adv-header-id-meta":"","stick-header-meta":"default","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","astra-migrate-meta-layouts":"default","ast-page-background-enabled":"default","ast-page-background-meta":{"desktop":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-gradient":""},"tablet":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-gradient":""},"mobile":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-gradient":""}},"ast-content-background-meta":{"desktop":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-gradient":""},"tablet":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-gradient":""},"mobile":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-gradient":""}}},"kbtopic":[43],"kbtag":[106],"mkb_version":[],"_links":{"self":[{"href":"https:\/\/www.casbay.com\/guide\/wp-json\/wp\/v2\/kb\/20685"}],"collection":[{"href":"https:\/\/www.casbay.com\/guide\/wp-json\/wp\/v2\/kb"}],"about":[{"href":"https:\/\/www.casbay.com\/guide\/wp-json\/wp\/v2\/types\/kb"}],"author":[{"embeddable":true,"href":"https:\/\/www.casbay.com\/guide\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.casbay.com\/guide\/wp-json\/wp\/v2\/comments?post=20685"}],"version-history":[{"count":13,"href":"https:\/\/www.casbay.com\/guide\/wp-json\/wp\/v2\/kb\/20685\/revisions"}],"predecessor-version":[{"id":36069,"href":"https:\/\/www.casbay.com\/guide\/wp-json\/wp\/v2\/kb\/20685\/revisions\/36069"}],"wp:attachment":[{"href":"https:\/\/www.casbay.com\/guide\/wp-json\/wp\/v2\/media?parent=20685"}],"wp:term":[{"taxonomy":"kbtopic","embeddable":true,"href":"https:\/\/www.casbay.com\/guide\/wp-json\/wp\/v2\/kbtopic?post=20685"},{"taxonomy":"kbtag","embeddable":true,"href":"https:\/\/www.casbay.com\/guide\/wp-json\/wp\/v2\/kbtag?post=20685"},{"taxonomy":"mkb_version","embeddable":true,"href":"https:\/\/www.casbay.com\/guide\/wp-json\/wp\/v2\/mkb_version?post=20685"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}