{"id":6790,"date":"2020-04-29T11:00:13","date_gmt":"2020-04-29T09:00:13","guid":{"rendered":"https:\/\/qodeinteractive.com\/magazine\/?p=6790"},"modified":"2020-09-04T00:38:23","modified_gmt":"2020-09-03T22:38:23","slug":"error-establishing-a-database-connection-in-wordpress","status":"publish","type":"post","link":"https:\/\/qodeinteractive.com\/magazine\/error-establishing-a-database-connection-in-wordpress\/","title":{"rendered":"How to Fix Error Establishing a Database Connection in WordPress"},"content":{"rendered":"<div class=\"wpb-content-wrapper\"><p>[vc_row][vc_column][vc_column_text]If you encounter an <em>Error establishing a database connection<\/em> notification in the window of your browser, <strong>your website is not able to connect to the WordPress database<\/strong>. The inability to establish a database connection is a serious error that prevents visitors from accessing your website. In this article, we\u2019ll show you how to fix the error in establishing a database connection in WordPress using several different methods:[\/vc_column_text][vc_empty_space height=&#8221;22px&#8221;]<ul class=\"qodef-unordered-list-item qodef-toc\">\n    <li>\n\t        <div class=\"qodef-ul-title-holder\">\n            <span class=\"qodef-ul-title-content\"><a href=\"#checking-database-access-credentials\">Checking database access credentials<\/a><\/span>        <\/div>\n            <\/li>\n<\/ul>[vc_empty_space height=&#8221;5px&#8221;]<ul class=\"qodef-unordered-list-item qodef-toc\">\n    <li>\n\t        <div class=\"qodef-ul-title-holder\">\n            <span class=\"qodef-ul-title-content\"><a href=\"#edit-the-wp-config-file\">Fixing the database by editing the wp-config.php file<\/a><\/span>        <\/div>\n            <\/li>\n<\/ul>[vc_empty_space height=&#8221;5px&#8221;]<ul class=\"qodef-unordered-list-item qodef-toc\">\n    <li>\n\t        <div class=\"qodef-ul-title-holder\">\n            <span class=\"qodef-ul-title-content\"><a href=\"#verify-database-server\">Verify if the database server is working <\/a><\/span>        <\/div>\n            <\/li>\n<\/ul>[vc_empty_space height=&#8221;70px&#8221;][\/vc_column][\/vc_row][vc_row][vc_column][vc_column_text]<\/p>\n<h2 class=\"qodef-h4\">What Is Error Establishing a Database Connection?<\/h2>\n<p>[\/vc_column_text][vc_column_text]All the relevant information about your WordPress site, such as information about posts, pages, plugin settings, user info, are kept in the database. <strong>WordPress connects with this database every time someone visits your website<\/strong>.[\/vc_column_text][vc_empty_space height=&#8221;28px&#8221;][vc_column_text]The database in question does not store media files (images and video) and plugins\/themes core files such as index.php, wp-login.php, etc.[\/vc_column_text][vc_empty_space height=&#8221;28px&#8221;][vc_column_text]When somebody visits your webpage, <strong>PHP executes the relevant code on the page and retrieves information from the database, displaying them to the site visitor in the browser<\/strong>.[\/vc_column_text][vc_empty_space height=&#8221;28px&#8221;][vc_column_text]To successfully establish the connection, you need the following information:[\/vc_column_text][vc_empty_space height=&#8221;23px&#8221;]<ul class=\"qodef-unordered-list-item \">\n    <li>\n\t        <div class=\"qodef-ul-title-holder\">\n            <span class=\"qodef-ul-title-content\">Database name<\/span>        <\/div>\n            <\/li>\n<\/ul><ul class=\"qodef-unordered-list-item \">\n    <li>\n\t        <div class=\"qodef-ul-title-holder\">\n            <span class=\"qodef-ul-title-content\">Database username<\/span>        <\/div>\n            <\/li>\n<\/ul><ul class=\"qodef-unordered-list-item \">\n    <li>\n\t        <div class=\"qodef-ul-title-holder\">\n            <span class=\"qodef-ul-title-content\">Database password<\/span>        <\/div>\n            <\/li>\n<\/ul><ul class=\"qodef-unordered-list-item \">\n    <li>\n\t        <div class=\"qodef-ul-title-holder\">\n            <span class=\"qodef-ul-title-content\">Database server<\/span>        <\/div>\n            <\/li>\n<\/ul>[vc_column_text]This information is found in the WordPress configuration file <em>wp-config.php<\/em>. In case one of these parameters is not correct, WordPress won\u2019t be able to connect with the database.[\/vc_column_text][vc_empty_space height=&#8221;28px&#8221;][vc_column_text]In that case, the browser window will display the <em>Error establishing a database connection<\/em> notification.[\/vc_column_text][vc_empty_space height=&#8221;50px&#8221;]<div class=\"qodef-single-image-holder   qodef-has-border \">\n    <div class=\"qodef-si-inner\" >\n                                    <img loading=\"lazy\" decoding=\"async\" width=\"700\" height=\"374\" src=\"https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2020\/04\/Error-establishing-a-database-connection.png\" class=\"attachment-full size-full\" alt=\"Error establishing a database connection notification\" srcset=\"https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2020\/04\/Error-establishing-a-database-connection.png 700w, https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2020\/04\/Error-establishing-a-database-connection-300x160.png 300w, https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2020\/04\/Error-establishing-a-database-connection-620x331.png 620w\" sizes=\"auto, (max-width: 700px) 100vw, 700px\" \/>                        <\/div>\n<\/div>[vc_empty_space height=&#8221;38px&#8221;][vc_column_text]Due to this error, <strong>you cannot access the front end of your site and WordPress admin panel<\/strong>.[\/vc_column_text][vc_empty_space height=&#8221;28px&#8221;][vc_column_text]Before you start troubleshooting, create a <a href=\"https:\/\/qodeinteractive.com\/magazine\/how-to-manually-backup-wordpress-website\/\">complete backup of your WordPress site<\/a>, since some of these steps will require editing the information about the database. It is recommended to <strong>regularly backup your site, especially if it is frequently under maintenance<\/strong>.[\/vc_column_text][vc_empty_space height=&#8221;72px&#8221;][\/vc_column][\/vc_row][vc_row][vc_column][vc_column_text]<\/p>\n<h3 class=\"qodef-h5\"><a id=\"checking-database-access-credentials\"><\/a>Checking Database Access Credentials<\/h3>\n<p>[\/vc_column_text][vc_column_text]One of the most common reasons for the error is incorrect access information, so this is where your troubleshooting needs to start. <strong>This issue is known to arise as you\u2019re moving the WordPress site from one host to another<\/strong>.[\/vc_column_text][vc_empty_space height=&#8221;28px&#8221;][vc_column_text]The information you need to access the database is located in WordPress configuration file <em>wp-config.php<\/em>. You\u2019ll find it in the root folder of your WordPress website. This file contains four lines of code (with the database name, user name, password, and host of the database) that have to be accurate to successfully establish a database connection.[\/vc_column_text][vc_empty_space height=&#8221;50px&#8221;]<div class=\"qodef-single-image-holder   qodef-has-border \">\n    <div class=\"qodef-si-inner\" >\n                                    <img loading=\"lazy\" decoding=\"async\" width=\"700\" height=\"374\" src=\"https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2020\/04\/2-Checking-database-access-data.jpg\" class=\"attachment-full size-full\" alt=\"Checking database access data\" srcset=\"https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2020\/04\/2-Checking-database-access-data.jpg 700w, https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2020\/04\/2-Checking-database-access-data-300x160.jpg 300w, https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2020\/04\/2-Checking-database-access-data-620x331.jpg 620w\" sizes=\"auto, (max-width: 700px) 100vw, 700px\" \/>                        <\/div>\n<\/div>[vc_empty_space height=&#8221;48px&#8221;]<div class=\"qodef-ordered-list-item \">\n\t        <div class=\"qodef-ol-title-holder\">\n            <span class=\"qodef-ol-title-number\">1.<\/span>\n            <span class=\"qodef-ol-title-content\">How to find database name, username, and password<\/span>        <\/div>\n    <\/div>[vc_column_text]You can easily find this information in your cPanel. <strong>Assuming your host uses cPanel, they should provide you with a direct link to access it somewhere in your welcome emails<\/strong>.[\/vc_column_text][vc_empty_space height=&#8221;28px&#8221;][vc_column_text]But, if you can\u2019t find that link, here\u2019s a tip to help you access your site\u2019s cPanel dashboard at any time:[\/vc_column_text][vc_empty_space height=&#8221;23px&#8221;]<ul class=\"qodef-unordered-list-item \">\n    <li>\n\t        <div class=\"qodef-ul-title-holder\">\n            <span class=\"qodef-ul-title-content\">If your site\u2019s URL starts with <strong>http<\/strong>, append <strong>:2082<\/strong> to the end of your domain name.<\/span>        <\/div>\n            <\/li>\n<\/ul><ul class=\"qodef-unordered-list-item \">\n    <li>\n\t        <div class=\"qodef-ul-title-holder\">\n            <span class=\"qodef-ul-title-content\">If your site\u2019s URL starts with <strong>https<\/strong>, append <strong>:2083<\/strong> to the end of your domain name.<\/span>        <\/div>\n            <\/li>\n<\/ul>[vc_column_text]So, you should be able to access cPanel by going to <em><strong>http:\/\/www.yoursite.com:2082 or https:\/\/www.yoursite.com:2083.<\/strong><\/em>[\/vc_column_text][vc_empty_space height=&#8221;28px&#8221;][vc_column_text]Once you\u2019ve found your cPanel address, <strong>log into your hosting account<\/strong> and click on the <em>MySQL databases<\/em> option in the <em>Databases section<\/em>.[\/vc_column_text][vc_empty_space height=&#8221;50px&#8221;]<div class=\"qodef-single-image-holder   qodef-has-border \">\n    <div class=\"qodef-si-inner\" >\n                                    <img loading=\"lazy\" decoding=\"async\" width=\"710\" height=\"378\" src=\"https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2020\/02\/MySQL-Databases.jpg\" class=\"attachment-full size-full\" alt=\"MySQL Databases\" srcset=\"https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2020\/02\/MySQL-Databases.jpg 710w, https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2020\/02\/MySQL-Databases-300x160.jpg 300w, https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2020\/02\/MySQL-Databases-620x330.jpg 620w\" sizes=\"auto, (max-width: 710px) 100vw, 710px\" \/>                        <\/div>\n<\/div>[vc_empty_space height=&#8221;38px&#8221;][vc_column_text]When you access the MySQL databases section, you\u2019ll see a single database belonging to your site, or a list of databases if your server is hosting multiple sites. Click on your site\u2019s database to open it.[\/vc_column_text][vc_empty_space height=&#8221;50px&#8221;]<div class=\"qodef-single-image-holder   qodef-has-border \">\n    <div class=\"qodef-si-inner\" >\n                                    <img loading=\"lazy\" decoding=\"async\" width=\"700\" height=\"374\" src=\"https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2020\/04\/4-Click-on-your-site\u2019s-database.jpg\" class=\"attachment-full size-full\" alt=\"Click on your site\u2019s database\" srcset=\"https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2020\/04\/4-Click-on-your-site\u2019s-database.jpg 700w, https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2020\/04\/4-Click-on-your-site\u2019s-database-300x160.jpg 300w, https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2020\/04\/4-Click-on-your-site\u2019s-database-620x331.jpg 620w\" sizes=\"auto, (max-width: 700px) 100vw, 700px\" \/>                        <\/div>\n<\/div>[vc_empty_space height=&#8221;38px&#8221;][vc_column_text]Then, if you want to find information about or make changes to a user account, find the column called <em>Privileged Users<\/em> and <strong>select the appropriate user name<\/strong>. When you click on <em>Manage User Privileges<\/em> you will be able to <strong>edit the user\u2019s database privileges and activate\/deactivate them<\/strong> as appropriate.[\/vc_column_text][vc_empty_space height=&#8221;50px&#8221;]<div class=\"qodef-single-image-holder   qodef-has-border \">\n    <div class=\"qodef-si-inner\" >\n                                    <img loading=\"lazy\" decoding=\"async\" width=\"700\" height=\"374\" src=\"https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2020\/04\/Manage-User-Privileges.jpg\" class=\"attachment-full size-full\" alt=\"Manage User Privileges\" srcset=\"https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2020\/04\/Manage-User-Privileges.jpg 700w, https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2020\/04\/Manage-User-Privileges-300x160.jpg 300w, https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2020\/04\/Manage-User-Privileges-620x331.jpg 620w\" sizes=\"auto, (max-width: 700px) 100vw, 700px\" \/>                        <\/div>\n<\/div>[vc_empty_space height=&#8221;38px&#8221;][vc_column_text]After you check the access information, you also have the <strong>option to change the password<\/strong>. Simply find your site\u2019s database in the MySQL list and click on the option to change the password.[\/vc_column_text][vc_empty_space height=&#8221;50px&#8221;]<div class=\"qodef-single-image-holder   qodef-has-border \">\n    <div class=\"qodef-si-inner\" >\n                                    <img loading=\"lazy\" decoding=\"async\" width=\"700\" height=\"374\" src=\"https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2020\/04\/5-Click-on-the-option-to-change-the-password.jpg\" class=\"attachment-full size-full\" alt=\"Click on the option to change the password\" srcset=\"https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2020\/04\/5-Click-on-the-option-to-change-the-password.jpg 700w, https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2020\/04\/5-Click-on-the-option-to-change-the-password-300x160.jpg 300w, https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2020\/04\/5-Click-on-the-option-to-change-the-password-620x331.jpg 620w\" sizes=\"auto, (max-width: 700px) 100vw, 700px\" \/>                        <\/div>\n<\/div>[vc_empty_space height=&#8221;38px&#8221;][vc_column_text]This is a good solution if you\u2019re not sure which password you chose or you want to reset it. You can also <strong>create a new user for your database<\/strong>.[\/vc_column_text][vc_empty_space height=&#8221;50px&#8221;]<div class=\"qodef-single-image-holder   qodef-has-border \">\n    <div class=\"qodef-si-inner\" >\n                                    <img loading=\"lazy\" decoding=\"async\" width=\"700\" height=\"374\" src=\"https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2020\/04\/6-Create-a-new-user-for-your-database.jpg\" class=\"attachment-full size-full\" alt=\"Create a new user for your database\" srcset=\"https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2020\/04\/6-Create-a-new-user-for-your-database.jpg 700w, https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2020\/04\/6-Create-a-new-user-for-your-database-300x160.jpg 300w, https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2020\/04\/6-Create-a-new-user-for-your-database-620x331.jpg 620w\" sizes=\"auto, (max-width: 700px) 100vw, 700px\" \/>                        <\/div>\n<\/div>[vc_empty_space height=&#8221;38px&#8221;][vc_column_text]When you create a new user, simply add it to your database using the following option.[\/vc_column_text][vc_empty_space height=&#8221;50px&#8221;]<div class=\"qodef-single-image-holder   qodef-has-border \">\n    <div class=\"qodef-si-inner\" >\n                                    <img loading=\"lazy\" decoding=\"async\" width=\"700\" height=\"374\" src=\"https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2020\/04\/7-Add-new-users-to-your-database.jpg\" class=\"attachment-full size-full\" alt=\"Add new users to your database\" srcset=\"https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2020\/04\/7-Add-new-users-to-your-database.jpg 700w, https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2020\/04\/7-Add-new-users-to-your-database-300x160.jpg 300w, https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2020\/04\/7-Add-new-users-to-your-database-620x331.jpg 620w\" sizes=\"auto, (max-width: 700px) 100vw, 700px\" \/>                        <\/div>\n<\/div>[vc_empty_space height=&#8221;38px&#8221;][vc_column_text]The name of the database and its compatibility with your website can be verified using the <em>phpMyAdmin<\/em> option from cPanel.[\/vc_column_text][vc_empty_space height=&#8221;50px&#8221;]<div class=\"qodef-single-image-holder   qodef-has-border \">\n    <div class=\"qodef-si-inner\" >\n                                    <img loading=\"lazy\" decoding=\"async\" width=\"710\" height=\"378\" src=\"https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2020\/02\/phpMyAdmin.jpg\" class=\"attachment-full size-full\" alt=\"phpMyAdmin\" srcset=\"https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2020\/02\/phpMyAdmin.jpg 710w, https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2020\/02\/phpMyAdmin-300x160.jpg 300w, https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2020\/02\/phpMyAdmin-620x330.jpg 620w\" sizes=\"auto, (max-width: 710px) 100vw, 710px\" \/>                        <\/div>\n<\/div>[vc_empty_space height=&#8221;38px&#8221;][vc_column_text]When you click on this option, you\u2019ll see the name of your database below the <em>information_schema database<\/em> used by your host. Click on your database name to <strong>see all the tables and data it stores<\/strong>.[\/vc_column_text][vc_empty_space height=&#8221;50px&#8221;]<div class=\"qodef-single-image-holder   qodef-has-border \">\n    <div class=\"qodef-si-inner\" >\n                                    <img loading=\"lazy\" decoding=\"async\" width=\"700\" height=\"374\" src=\"https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2020\/04\/8-see-all-the-tables-and-data-it-stores.jpg\" class=\"attachment-full size-full\" alt=\"See all the tables and data it stores\" srcset=\"https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2020\/04\/8-see-all-the-tables-and-data-it-stores.jpg 700w, https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2020\/04\/8-see-all-the-tables-and-data-it-stores-300x160.jpg 300w, https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2020\/04\/8-see-all-the-tables-and-data-it-stores-620x331.jpg 620w\" sizes=\"auto, (max-width: 700px) 100vw, 700px\" \/>                        <\/div>\n<\/div>[vc_empty_space height=&#8221;38px&#8221;][vc_column_text]To verify that the database is compatible with your website, click on the <em>wp_options table<\/em>. <strong>In the field siteurl check the entered value for the URL address<\/strong>. If everything is working fine, then your database is compatible with the website.[\/vc_column_text][vc_empty_space height=&#8221;50px&#8221;]<div class=\"qodef-single-image-holder   qodef-has-border \">\n    <div class=\"qodef-si-inner\" >\n                                    <img loading=\"lazy\" decoding=\"async\" width=\"700\" height=\"374\" src=\"https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2020\/04\/9-Database-is-compatible-with-the-website.jpg\" class=\"attachment-full size-full\" alt=\"Database is compatible with the website\" srcset=\"https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2020\/04\/9-Database-is-compatible-with-the-website.jpg 700w, https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2020\/04\/9-Database-is-compatible-with-the-website-300x160.jpg 300w, https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2020\/04\/9-Database-is-compatible-with-the-website-620x331.jpg 620w\" sizes=\"auto, (max-width: 700px) 100vw, 700px\" \/>                        <\/div>\n<\/div>[vc_empty_space height=&#8221;38px&#8221;][vc_column_text]After you verify the information about the database name, username, and password, you can change this information by <a href=\"https:\/\/qodeinteractive.com\/magazine\/how-to-edit-wp-config-file\/\">modifying your wp-config.php file<\/a> if there\u2019s a need (if you created a new user, it is mandatory).[\/vc_column_text][vc_empty_space height=&#8221;28px&#8221;][vc_column_text]After that, refresh your site to check if the error is gone. [\/vc_column_text][vc_empty_space height=&#8221;38px&#8221;]<div class=\"qodef-ordered-list-item \">\n\t        <div class=\"qodef-ol-title-holder\">\n            <span class=\"qodef-ol-title-number\">2.<\/span>\n            <span class=\"qodef-ol-title-content\">Check the database host information<\/span>        <\/div>\n    <\/div>[vc_column_text]If the name of the database, username, and password are correct and the error is still there, you need to <strong>verify if the information about the database host is input correctly<\/strong>.[\/vc_column_text][vc_empty_space height=&#8221;28px&#8221;][vc_column_text]A lot of WordPress hosting companies use <em>localhost<\/em> as the host for the database. However, some hosting providers use separate servers for host databases. In that case, <strong>contact your WordPress hosting provider<\/strong> to check information about the host of your database.[\/vc_column_text][vc_empty_space height=&#8221;28px&#8221;][vc_column_text]You can also consult a list of <a href=\"https:\/\/wordpress.org\/support\/article\/editing-wp-config-php\/\" target=\"_blank\" rel=\"noopener noreferrer\">POSSIBLE DB_HOST VALUES provided by WordPress<\/a>. It contains parameters used by some of the popular WordPress hosting providers so you might find the information you\u2019re looking for there.[\/vc_column_text][vc_empty_space height=&#8221;72px&#8221;][\/vc_column][\/vc_row][vc_row][vc_column][vc_column_text]<\/p>\n<h3 class=\"qodef-h5\"><a id=\"edit-the-wp-config-file\"><\/a>Fixing the Database by Editing the wp-config.php File<\/h3>\n<p>[\/vc_column_text][vc_column_text]In some cases, a damaged database may be the cause of connection error. This is a rare occurrence. It usually happens <strong>when you add a large number of tables to the database in the process of adding and removing plugins and themes<\/strong>.[\/vc_column_text][vc_empty_space height=&#8221;28px&#8221;][vc_column_text]After you log into your admin panel, you\u2019ll see error notifications indicating that your database is damaged, such as <em>One or more database tables are unavailable<\/em>. or <em>The database may need to be repaired<\/em>.[\/vc_column_text][vc_empty_space height=&#8221;28px&#8221;][vc_column_text]If this happens, it\u2019s important to know that WordPress has a mode that you can initiate to eliminate this error. [\/vc_column_text][vc_empty_space height=&#8221;28px&#8221;][vc_column_text]Access the wp-config.php file and insert the following code before the line \u2018That\u2019s all, stop editing! Happy blogging\u2019[\/vc_column_text][vc_empty_space height=&#8221;50px&#8221;][vc_column_text]<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">define('WP_ALLOW_REPAIR', true);<\/pre>\n<p>[\/vc_column_text][vc_empty_space height=&#8221;39px&#8221;]<div class=\"qodef-single-image-holder   qodef-has-border \">\n    <div class=\"qodef-si-inner\" >\n                                    <img loading=\"lazy\" decoding=\"async\" width=\"700\" height=\"374\" src=\"https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2020\/04\/10-Fix-Error-Establishing-a-Database-Connection.jpg\" class=\"attachment-full size-full\" alt=\"Fix Error Establishing a Database Connection\" srcset=\"https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2020\/04\/10-Fix-Error-Establishing-a-Database-Connection.jpg 700w, https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2020\/04\/10-Fix-Error-Establishing-a-Database-Connection-300x160.jpg 300w, https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2020\/04\/10-Fix-Error-Establishing-a-Database-Connection-620x331.jpg 620w\" sizes=\"auto, (max-width: 700px) 100vw, 700px\" \/>                        <\/div>\n<\/div>[vc_empty_space height=&#8221;38px&#8221;][vc_column_text]To see the settings for fixing the database, <strong>add the following link to your browser<\/strong>. [\/vc_column_text][vc_empty_space height=&#8221;28px&#8221;][vc_column_text]<strong><em>http:\/\/www.yourwebsite.com\/wp-admin\/maint\/repair.php<\/em><\/strong>[\/vc_column_text][vc_empty_space height=&#8221;50px&#8221;]<div class=\"qodef-single-image-holder   qodef-has-border \">\n    <div class=\"qodef-si-inner\" >\n                                    <img loading=\"lazy\" decoding=\"async\" width=\"700\" height=\"374\" src=\"https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2020\/04\/11-Settings-for-fixing-the-database.jpg\" class=\"attachment-full size-full\" alt=\"Settings for fixing the database\" srcset=\"https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2020\/04\/11-Settings-for-fixing-the-database.jpg 700w, https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2020\/04\/11-Settings-for-fixing-the-database-300x160.jpg 300w, https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2020\/04\/11-Settings-for-fixing-the-database-620x331.jpg 620w\" sizes=\"auto, (max-width: 700px) 100vw, 700px\" \/>                        <\/div>\n<\/div>[vc_empty_space height=&#8221;38px&#8221;][vc_column_text]Replace yourwebsite.com with your website\u2019s URL.[\/vc_column_text][vc_empty_space height=&#8221;28px&#8221;][vc_column_text]You don\u2019t have to be logged into the admin panel to access this page. When it opens, it\u2019s enough to click on the button for fixing the database. This will start the process that may take a while. <strong>When you fix the database, remove the code you previously added to the <em>wp-config.php<\/em> file<\/strong>.[\/vc_column_text][vc_empty_space height=&#8221;50px&#8221;]<div class=\"qodef-single-image-holder   qodef-has-border \">\n    <div class=\"qodef-si-inner\" >\n                                    <img loading=\"lazy\" decoding=\"async\" width=\"700\" height=\"374\" src=\"https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2020\/04\/12-Database-Connection-in-WordPress.jpg\" class=\"attachment-full size-full\" alt=\"Database Connection in WordPress\" srcset=\"https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2020\/04\/12-Database-Connection-in-WordPress.jpg 700w, https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2020\/04\/12-Database-Connection-in-WordPress-300x160.jpg 300w, https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2020\/04\/12-Database-Connection-in-WordPress-620x331.jpg 620w\" sizes=\"auto, (max-width: 700px) 100vw, 700px\" \/>                        <\/div>\n<\/div>[vc_empty_space height=&#8221;90px&#8221;][vc_separator color=&#8221;custom&#8221; accent_color=&#8221;#f0f0f0&#8243;][vc_empty_space height=&#8221;50px&#8221;][vc_widget_sidebar sidebar_id=&#8221;top-picks-banner&#8221;][vc_empty_space height=&#8221;28px&#8221;][vc_separator color=&#8221;custom&#8221; accent_color=&#8221;#f0f0f0&#8243;][vc_empty_space height=&#8221;72px&#8221;][\/vc_column][\/vc_row][vc_row][vc_column][vc_column_text]<\/p>\n<h3 class=\"qodef-h5\"><a id=\"verify-database-server\"><\/a>Verify If the Database Server Is Working<\/h3>\n<p>[\/vc_column_text][vc_column_text]If your information for database access is correct, and you still cannot establish a database connection, you should <strong>inspect the database server (MySQL server)<\/strong>.[\/vc_column_text][vc_empty_space height=&#8221;28px&#8221;][vc_column_text]Large traffic on the server is one of the possible causes of a database server crash. Many hosting providers have limitations on their servers regarding traffic. This means it\u2019s more likely that <strong>your server won\u2019t be able to deal with large traffic, especially if you have shared hosting<\/strong>. Also, if there is an overload on your database server, your website\u2019s speed decreases and some visitors may even get an error message when they try to access it.[\/vc_column_text][vc_empty_space height=&#8221;28px&#8221;][vc_column_text]One way you can solve this is by <a href=\"https:\/\/qodeinteractive.com\/magazine\/best-wordpress-caching-plugins\/\">using cache plugins<\/a>. They can help decrease database interactions on your website. A cache plugin creates a lighter HTML version of your page that it serves up to visitors. That way the server doesn\u2019t have to execute PHP code and MySQL database queries with each new page visit.[\/vc_column_text][vc_empty_space height=&#8221;28px&#8221;][vc_column_text]Alternatively, <strong>contact your hosting provider and ask them to examine whether your MySQL server is functioning properly<\/strong>.[\/vc_column_text][vc_empty_space height=&#8221;28px&#8221;][vc_column_text]<strong>If you have multiple sites on the server, check all of them<\/strong> to see if the MySQL server is working at a decreased speed. And after the hosting provider verifies your database server is functioning properly, run a quick test with your live site to see if the error is still there.[\/vc_column_text][vc_empty_space height=&#8221;72px&#8221;][\/vc_column][\/vc_row][vc_row][vc_column][vc_column_text]<\/p>\n<h2 class=\"qodef-h4\">Final Tips<\/h2>\n<p>[\/vc_column_text][vc_column_text]There is no way to completely prevent the error establishing a database connection in WordPress. However, there are ways to minimize the risk\u2014ensure your database access credentials are valid, purchase high-quality hosting, and do regular website backups. [\/vc_column_text][vc_empty_space height=&#8221;28px&#8221;][vc_column_text]Choose hosting providers whose platforms are optimized for WordPress. This way, you can always count on their support. At the same time, you\u2019ll avoid small glitches and errors caused by incompatibilities with WordPress.[\/vc_column_text][vc_empty_space height=&#8221;28px&#8221;][vc_column_text]Regular site backups should be a part of your site management daily routine. You can do this <a href=\"https:\/\/qodeinteractive.com\/magazine\/wordpress-backup-with-updraft-plus-plugin\/\">using backup plugins<\/a> that allow you to automate the process, or you can backup your WordPress website manually. This way, if your site crashes, you\u2019ll always have a ready-to-go copy that allows you to revert to your last working settings before you start troubleshooting.[\/vc_column_text][\/vc_column][\/vc_row]<\/p>\n<\/div>","protected":false},"excerpt":{"rendered":"<p>What do you do when you get an error establishing a database connection in WordPress? Take a look at our guide and learn how to troubleshoot it, of course.<\/p>\n","protected":false},"author":10600,"featured_media":7779,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[7],"tags":[14,52,13],"class_list":["post-6790","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-tutorials","tag-core","tag-troubleshooting","tag-wordpress"],"_links":{"self":[{"href":"https:\/\/qodeinteractive.com\/magazine\/wp-json\/wp\/v2\/posts\/6790","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/qodeinteractive.com\/magazine\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/qodeinteractive.com\/magazine\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/qodeinteractive.com\/magazine\/wp-json\/wp\/v2\/users\/10600"}],"replies":[{"embeddable":true,"href":"https:\/\/qodeinteractive.com\/magazine\/wp-json\/wp\/v2\/comments?post=6790"}],"version-history":[{"count":0,"href":"https:\/\/qodeinteractive.com\/magazine\/wp-json\/wp\/v2\/posts\/6790\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/qodeinteractive.com\/magazine\/wp-json\/wp\/v2\/media\/7779"}],"wp:attachment":[{"href":"https:\/\/qodeinteractive.com\/magazine\/wp-json\/wp\/v2\/media?parent=6790"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/qodeinteractive.com\/magazine\/wp-json\/wp\/v2\/categories?post=6790"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/qodeinteractive.com\/magazine\/wp-json\/wp\/v2\/tags?post=6790"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}