{"id":583,"date":"2016-06-01T00:00:00","date_gmt":"2016-06-01T00:00:00","guid":{"rendered":"http:\/\/blog.hostinger.io\/hostinger-tutorials\/uncategorized\/wordpresswordpress-error-establishing-database-connection\/"},"modified":"2026-03-10T10:13:25","modified_gmt":"2026-03-10T10:13:25","slug":"wordpress-error-establishing-database-connection","status":"publish","type":"post","link":"\/uk\/tutorials\/wordpress-error-establishing-database-connection","title":{"rendered":"How to Fix &#8220;Error Establishing A Database Connection&#8221; in WordPress"},"content":{"rendered":"<p>&ldquo;Error Establishing a Database Connection&rdquo; occurs when your WordPress website can&rsquo;t connect and retrieve information from the database. Its common causes include misconfigurations in the <strong>wp-config<\/strong> file, invalid credentials, or corrupted data.<\/p><p>If left alone, this database problem can harm your website&rsquo;s uptime and usability. But don&rsquo;t worry &ndash; we&rsquo;re here to help you identify the root issue and resolve this error quickly.<\/p><p>This WordPress tutorial will explain all about &ldquo;Error Establishing a Database Connection,&rdquo; its possible causes, and tried-and-true solutions. We&rsquo;ll also explore the best practices to prevent this error from happening again.<\/p><p class=\"has-text-align-center\"><a href=\"https:\/\/assets.hostinger.com\/content\/tutorials\/pdf\/Mega-WordPress-Cheat-EN.pdf\" target=\"_blank\" rel=\"noopener\">Download all in one WordPress cheat sheet<\/a><\/p><figure tabindex=\"0\" class=\"wp-block-table\"><table><tbody><tr><td><strong>Error code<\/strong><\/td><td>Error establishing a database connection<\/td><\/tr><tr><td><strong>Error type<\/strong><\/td><td>Database error<\/td><\/tr><tr><td><strong>Error causes<\/strong><\/td><td>Mismatched information between <strong>wp-config<\/strong> and the WordPress database<br>Incorrect database credentials<br>Database corruption<br>Corrupted core files<\/td><\/tr><\/tbody><\/table><\/figure><p>\n\n\n<div class=\"protip\">\n                    <h2 class=\"featured-snippet title\">What Is Error Establishing a Database Connection?<\/h2>\n                    <p><br>\n&ldquo;Error Establishing a Database Connection&rdquo; is an issue that occurs when your WordPress site can&rsquo;t connect and retrieve information from the database. It can cause a malfunction or downtime on your site.<br>\nThe common causes for this error include mismatched configuration, invalid credentials, failed databases, and corrupted core files.<\/p>\n                <\/div>\n\n\n\n<\/p><p>When someone visits your WordPress site, specific <strong>PHP<\/strong> commands fetch information from the database. This data will show up on the visitor&rsquo;s browser, displaying the requested web page.<\/p><p>However, misconfigurations or data corruption can cause the database connection to fail. Since it can&rsquo;t retrieve data, the WordPress &ldquo;Error establishing a database connection&rdquo; message will appear instead.<\/p><div class=\"wp-block-image\"><figure class=\"aligncenter size-large\"><a href=\"\/uk\/tutorials\/wp-content\/uploads\/sites\/2\/2016\/06\/the-error-establishing-database-connection-message.png\"><img decoding=\"async\" width=\"1024\" height=\"202\" src=\"\/tutorials\/wp-content\/uploads\/sites\/2\/2016\/06\/the-error-establishing-database-connection-message-1024x202.png\" alt=\"The error establishing database connection message\" class=\"wp-image-104810\" srcset=\"https:\/\/www.hostinger.com\/uk\/tutorials\/wp-content\/uploads\/sites\/51\/2016\/06\/the-error-establishing-database-connection-message.png 1024w, https:\/\/www.hostinger.com\/uk\/tutorials\/wp-content\/uploads\/sites\/51\/2016\/06\/the-error-establishing-database-connection-message-300x59.png 300w, https:\/\/www.hostinger.com\/uk\/tutorials\/wp-content\/uploads\/sites\/51\/2016\/06\/the-error-establishing-database-connection-message-150x30.png 150w, https:\/\/www.hostinger.com\/uk\/tutorials\/wp-content\/uploads\/sites\/51\/2016\/06\/the-error-establishing-database-connection-message-768x151.png 768w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure><\/div><p>Note that this message might not show up if the <a href=\"\/uk\/tutorials\/website-cache\">web page cache<\/a> is available, often making the error difficult to notice at first. However, an inaccessible admin dashboard can indicate this WordPress database connection error.<\/p><h3 class=\"wp-block-heading\" id=\"h-what-causes-error-establishing-a-database-connection-in-wordpress\">What Causes &ldquo;Error Establishing a Database Connection&rdquo; in WordPress<\/h3><p>Several common causes for &ldquo;Error Establishing a Database Connection&rdquo; in WordPress include:<\/p><ul class=\"wp-block-list\">\n<li><strong>Incorrect database login credentials in the wp-config file<\/strong>.<strong> <\/strong>The WordPress database uses login information from your hosting provider. If you modify the <a href=\"\/uk\/tutorials\/what-is-mysql\">MySQL database<\/a> password and username, the old credentials in your configuration files will be invalid.<\/li>\n\n\n\n<li><strong>Corrupted database<\/strong>.<strong> <\/strong>Faulty plugins or incompatible themes can corrupt database tables and their content, resulting in errors.<\/li>\n\n\n\n<li><strong>Database server error<\/strong>. Issues on your web host&rsquo;s infrastructure might cause a database error. For instance,<strong> <\/strong>traffic surges or permission issues can make the back end unresponsive.<\/li>\n\n\n\n<li><strong>Core file corruption<\/strong>. WordPress core files define how your site works and functions. Faulty code in plugins and themes can corrupt them, causing database failure.<\/li>\n<\/ul><p>The pop-up message can help you identify the culprit. For example, if you see the following error window on your WordPress site&rsquo;s admin dashboard, the reason is likely incorrect database login credentials.<\/p><div class=\"wp-block-image\"><figure class=\"aligncenter size-large\"><a href=\"\/uk\/tutorials\/wp-content\/uploads\/sites\/2\/2016\/06\/error-establishing-database-connection-with-potential-causes.png\"><img decoding=\"async\" width=\"1024\" height=\"407\" src=\"\/tutorials\/wp-content\/uploads\/sites\/2\/2016\/06\/error-establishing-database-connection-with-potential-causes-1024x407.png\" alt=\"The error establishing database connection message with potential causes\" class=\"wp-image-104811\" srcset=\"https:\/\/www.hostinger.com\/uk\/tutorials\/wp-content\/uploads\/sites\/51\/2016\/06\/error-establishing-database-connection-with-potential-causes.png 1024w, https:\/\/www.hostinger.com\/uk\/tutorials\/wp-content\/uploads\/sites\/51\/2016\/06\/error-establishing-database-connection-with-potential-causes-300x119.png 300w, https:\/\/www.hostinger.com\/uk\/tutorials\/wp-content\/uploads\/sites\/51\/2016\/06\/error-establishing-database-connection-with-potential-causes-150x60.png 150w, https:\/\/www.hostinger.com\/uk\/tutorials\/wp-content\/uploads\/sites\/51\/2016\/06\/error-establishing-database-connection-with-potential-causes-768x305.png 768w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure><\/div><h2 class=\"wp-block-heading\" id=\"h-how-to-fix-the-wordpress-error-establishing-a-database-connection-in-8-methods\">How to Fix the WordPress &ldquo;Error Establishing a Database Connection&rdquo; in 8 Methods<\/h2><p>After understanding the common reasons for the &ldquo;Error Establishing a Database Connection&rdquo; message, you will learn eight solutions to resolve it. Before proceeding, <a href=\"\/uk\/tutorials\/backup-wordpress\">back up your WordPress site<\/a> to avoid further damage due to misconfigurations.<\/p><h3 class=\"wp-block-heading\" id=\"h-1-check-your-database-server\">1. Check Your Database Server<\/h3><p>A database has a maximum number of connected clients. The server will drop connections if it exceeds the limit, causing downtime and preventing your website from fetching the requested data.<\/p><p>For this reason, a traffic surge commonly triggers &ldquo;Error Establishing a Database Connection&rdquo;. To resolve it, minimize your server back-end requests using caching plugins like <a href=\"https:\/\/wp-rocket.me\/\" target=\"_blank\" rel=\"noreferrer noopener\">W3 Total Cache<\/a> or <a href=\"https:\/\/wp-rocket.me\/\" target=\"_blank\" rel=\"noreferrer noopener\">WP Rocket<\/a>.<\/p><p>Network issues might also cause the error message. We recommend contacting your web host to check if all WordPress sites on the same server are experiencing the same issue. If so, the error is on the hosting provider&rsquo;s end.<\/p><p>Another common cause for an unresponsive server is insufficient user permissions. If your WordPress database user doesn&rsquo;t have the proper access permissions, it can&rsquo;t connect and retrieve content from the back end.<\/p><p>To check if the database user has the correct privileges, <a href=\"\/uk\/tutorials\/how-to-connect-php-to-mysql\">access the MySQL server using PHP<\/a>. Here&rsquo;s how to do so with a Hostinger plan:<\/p><ol class=\"wp-block-list\">\n<li>Log in to<strong> hPanel<\/strong>. Select <strong>Website<\/strong> on the top menu and click<strong> Dashboard<\/strong> on the website you want to configure.<\/li>\n\n\n\n<li>On the website management page, select <strong>File manager<\/strong>.<\/li>\n<\/ol><div class=\"wp-block-image\"><figure class=\"aligncenter size-large\"><a href=\"\/uk\/tutorials\/wp-content\/uploads\/sites\/2\/2016\/06\/file-manager-button-in-hpanel-website-management-menu.png\"><img decoding=\"async\" width=\"1024\" height=\"384\" src=\"\/tutorials\/wp-content\/uploads\/sites\/2\/2016\/06\/file-manager-button-in-hpanel-website-management-menu-1024x384.png\" alt=\"The File Manager button in hPanel's website management menu\" class=\"wp-image-104812\" srcset=\"https:\/\/www.hostinger.com\/uk\/tutorials\/wp-content\/uploads\/sites\/51\/2016\/06\/file-manager-button-in-hpanel-website-management-menu-1024x384.png 1024w, https:\/\/www.hostinger.com\/uk\/tutorials\/wp-content\/uploads\/sites\/51\/2016\/06\/file-manager-button-in-hpanel-website-management-menu-300x113.png 300w, https:\/\/www.hostinger.com\/uk\/tutorials\/wp-content\/uploads\/sites\/51\/2016\/06\/file-manager-button-in-hpanel-website-management-menu-150x56.png 150w, https:\/\/www.hostinger.com\/uk\/tutorials\/wp-content\/uploads\/sites\/51\/2016\/06\/file-manager-button-in-hpanel-website-management-menu-768x288.png 768w, https:\/\/www.hostinger.com\/uk\/tutorials\/wp-content\/uploads\/sites\/51\/2016\/06\/file-manager-button-in-hpanel-website-management-menu.png 1303w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure><\/div><ol start=\"3\" class=\"wp-block-list\">\n<li>Navigate to the <strong>public_html<\/strong> folder and click the <strong>Create a New File<\/strong> icon on the left sidebar.<\/li>\n\n\n\n<li>Create a new<strong> PHP<\/strong> file with any name. We will use <strong>test.php<\/strong> for this tutorial.<\/li>\n\n\n\n<li>Paste the following code into the file. Remember to replace the MySQL database password and username with the actual value.<\/li>\n<\/ol><pre class=\"wp-block-preformatted\">&lt;?php\n$link = mysqli_connect('localhost', 'username', 'password');\nif (!$link) {\ndie('Could not connect: ' . mysqli_error());\n}\necho 'Connected successfully';\nmysqli_close($link);\n?&gt;<\/pre><ol start=\"6\" class=\"wp-block-list\">\n<li>Click the <strong>disk <\/strong>icon on the top right corner to save the file.<\/li>\n\n\n\n<li>Open a new tab in your web browser and access the file by entering the file name and path after the domain like so:<\/li>\n<\/ol><pre class=\"wp-block-preformatted\">domain.com\/public_html\/test.php<\/pre><p>If the <a href=\"\/uk\/tutorials\/debug-wordpress\">WordPress debug<\/a> script doesn&rsquo;t return an error, your database user has sufficient permissions, and the connection should work normally.<\/p><div class=\"wp-block-image\"><figure class=\"aligncenter size-large\"><a href=\"\/uk\/tutorials\/wp-content\/uploads\/sites\/2\/2016\/06\/php-test-script-indicates-successful-database-connection.png\"><img decoding=\"async\" width=\"1024\" height=\"135\" src=\"\/tutorials\/wp-content\/uploads\/sites\/2\/2016\/06\/php-test-script-indicates-successful-database-connection-1024x135.png\" alt=\"php-test-script-indicates-successful-database-connection\" class=\"wp-image-104815\" srcset=\"https:\/\/www.hostinger.com\/uk\/tutorials\/wp-content\/uploads\/sites\/51\/2016\/06\/php-test-script-indicates-successful-database-connection.png 1024w, https:\/\/www.hostinger.com\/uk\/tutorials\/wp-content\/uploads\/sites\/51\/2016\/06\/php-test-script-indicates-successful-database-connection-300x40.png 300w, https:\/\/www.hostinger.com\/uk\/tutorials\/wp-content\/uploads\/sites\/51\/2016\/06\/php-test-script-indicates-successful-database-connection-150x20.png 150w, https:\/\/www.hostinger.com\/uk\/tutorials\/wp-content\/uploads\/sites\/51\/2016\/06\/php-test-script-indicates-successful-database-connection-768x101.png 768w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure><\/div><p>Otherwise, adjust the user permissions to ensure a successful database connection. On hPanel, access it by navigating to <strong>Databases<\/strong> &rarr; <strong>List of Current MySQL Databases And Users<\/strong>. <\/p><p>Click the <strong>three-dot <\/strong>icon next to the account and select <strong>Change Permissions<\/strong>. Check all the boxes and select<strong> Update<\/strong>. Rerun the debug script to check if the issue persists.<\/p><h3 class=\"wp-block-heading\" id=\"h-2-check-the-database-credentials\">2. Check the Database Credentials<\/h3><p>Incorrect login credentials are another common reason for the &ldquo;Error Establishing a Database Connection&rdquo; message. This usually happens after migrating a WordPress site to a new hosting provider.<\/p><p>To fix it, check if the database host information in your hosting control panel and <strong>wp-config.php<\/strong> file matches. If you can&rsquo;t access your hosting control panel, <a href=\"\/uk\/tutorials\/ftp\/filezilla-ftp-configuration\">use an FTP client like FileZilla<\/a> to view your site files.<\/p><p>While the general procedure is similar, the steps might differ. For example, you must manually download the file, edit it, and reupload it. At Hostinger, you can directly do so in a web browser via the <strong>File Manager <\/strong>on <strong>hPanel<\/strong>.<\/p><div class=\"wp-block-image\"><figure class=\"aligncenter size-large\"><a href=\"\/uk\/tutorials\/wp-content\/uploads\/sites\/2\/2016\/06\/database-information-in-wp-config.png\"><img decoding=\"async\" width=\"1024\" height=\"276\" src=\"\/tutorials\/wp-content\/uploads\/sites\/2\/2016\/06\/database-information-in-wp-config-1024x276.png\" alt=\"Database information in wp-config file\" class=\"wp-image-104816\" srcset=\"https:\/\/www.hostinger.com\/uk\/tutorials\/wp-content\/uploads\/sites\/51\/2016\/06\/database-information-in-wp-config.png 1024w, https:\/\/www.hostinger.com\/uk\/tutorials\/wp-content\/uploads\/sites\/51\/2016\/06\/database-information-in-wp-config-300x81.png 300w, https:\/\/www.hostinger.com\/uk\/tutorials\/wp-content\/uploads\/sites\/51\/2016\/06\/database-information-in-wp-config-150x40.png 150w, https:\/\/www.hostinger.com\/uk\/tutorials\/wp-content\/uploads\/sites\/51\/2016\/06\/database-information-in-wp-config-768x207.png 768w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure><\/div><p>After opening <strong>File Manager<\/strong>, locate the <strong>wp-config.php<\/strong> file within the <strong>public_html<\/strong> directory. Right-click on it and select <strong>Edit<\/strong>. Find the following database information:<\/p><ul class=\"wp-block-list\">\n<li><strong>DB_NAME<\/strong> &ndash; database name<\/li>\n\n\n\n<li><strong>DB_USER<\/strong> &ndash; database username<\/li>\n\n\n\n<li><strong>DB_PASSWORD<\/strong> &ndash; database password<\/li>\n\n\n\n<li><strong>DB_HOST<\/strong> &ndash; database host<\/li>\n<\/ul><p>Save this database host information in a safe location since we will compare them with the one on your hosting account. Then, return to <strong>hPanel<\/strong> and go to <strong>Database <\/strong>&rarr;<strong> Management<\/strong>.<\/p><div class=\"wp-block-image\"><figure class=\"aligncenter size-large\"><a href=\"\/uk\/tutorials\/wp-content\/uploads\/sites\/2\/2016\/06\/database-information-in-hpanel.png\"><img decoding=\"async\" width=\"1024\" height=\"241\" src=\"\/tutorials\/wp-content\/uploads\/sites\/2\/2016\/06\/database-information-in-hpanel-1024x241.png\" alt=\"The database information in hPanel\" class=\"wp-image-104819\" srcset=\"https:\/\/www.hostinger.com\/uk\/tutorials\/wp-content\/uploads\/sites\/51\/2016\/06\/database-information-in-hpanel-1024x241.png 1024w, https:\/\/www.hostinger.com\/uk\/tutorials\/wp-content\/uploads\/sites\/51\/2016\/06\/database-information-in-hpanel-300x71.png 300w, https:\/\/www.hostinger.com\/uk\/tutorials\/wp-content\/uploads\/sites\/51\/2016\/06\/database-information-in-hpanel-150x35.png 150w, https:\/\/www.hostinger.com\/uk\/tutorials\/wp-content\/uploads\/sites\/51\/2016\/06\/database-information-in-hpanel-768x181.png 768w, https:\/\/www.hostinger.com\/uk\/tutorials\/wp-content\/uploads\/sites\/51\/2016\/06\/database-information-in-hpanel.png 1297w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure><\/div><p>Check all the database information under the <strong>List of Current MySQL Databases And Users<\/strong> section. If the credentials in your <strong>wp-config <\/strong>file and <strong>MySQL database<\/strong> settings match, but the issue persists, proceed to the next solution.<\/p><p>If the information doesn&rsquo;t match, enter the correct database credentials from your hosting control panel. To do so, add the following code into <strong>wp-config.php<\/strong>:<\/p><pre class=\"wp-block-preformatted\">define('DB_NAME', 'fill_this_with_your_current_database_name');\n\ndefine('DB_USER', 'fill_this_with_your_current_username');\n\ndefine('DB_HOST', 'fill_this_with_your_current_localhost');<\/pre><p>Replace the placeholders with the correct information. Once finished, click the <strong>disk<\/strong> icon to save the changes. Refresh WordPress to see whether the &ldquo;Error Establishing a Database Connection&rdquo; on the website is resolved.<\/p><p>If the error persists, reset the database password from the <strong>List of Current MySQL Databases And Users<\/strong> section. Click the <strong>three dots<\/strong> icon &rarr; <strong>Change Password<\/strong>. Enter the new password and hit <strong>Update<\/strong>.<\/p><div class=\"wp-block-image\"><figure class=\"aligncenter size-full\"><a href=\"\/uk\/tutorials\/wp-content\/uploads\/sites\/2\/2016\/06\/new-database-password-creation-hpanel.png\"><img decoding=\"async\" width=\"974\" height=\"234\" src=\"\/tutorials\/wp-content\/uploads\/sites\/2\/2016\/06\/new-database-password-creation-hpanel.png\" alt=\"The new database password creation window in hPanel\" class=\"wp-image-104821\" srcset=\"https:\/\/www.hostinger.com\/uk\/tutorials\/wp-content\/uploads\/sites\/51\/2016\/06\/new-database-password-creation-hpanel.png 974w, https:\/\/www.hostinger.com\/uk\/tutorials\/wp-content\/uploads\/sites\/51\/2016\/06\/new-database-password-creation-hpanel-300x72.png 300w, https:\/\/www.hostinger.com\/uk\/tutorials\/wp-content\/uploads\/sites\/51\/2016\/06\/new-database-password-creation-hpanel-150x36.png 150w, https:\/\/www.hostinger.com\/uk\/tutorials\/wp-content\/uploads\/sites\/51\/2016\/06\/new-database-password-creation-hpanel-768x185.png 768w\" sizes=\"(max-width: 974px) 100vw, 974px\" \/><\/a><\/figure><\/div><p>If you used the correct database username and password, but the &ldquo;Error Establishing a Database Connection&rdquo; message still shows up, check the <strong>wp-config.php<\/strong> file&rsquo;s <strong>DB_HOST<\/strong> value. It should be <strong>localhost<\/strong>, <strong>127.0.0.1<\/strong>, or a<strong> URL<\/strong>, depending on your hosting provider.<\/p><p>Ask your hosting provider for the correct value. However, if you haven&rsquo;t <a href=\"\/uk\/tutorials\/how-to-migrate-wordpress\">migrated your WordPress site<\/a> recently, the MySQL hostname should not be the problem.<\/p><h3 class=\"wp-block-heading\" id=\"h-3-fix-corrupted-files\">3. Fix Corrupted Files<\/h3><p>Besides a faulty database, corrupted files can also trigger the &ldquo;Error Establishing a Database Connection&rdquo; message. It might be due to faulty themes or plugins since their code might conflict with the WordPress codebase.<\/p><p>To resolve the issue, deactivate the latest plugin or theme you downloaded since they are most likely the culprit. If you have several third-party software, we recommend disabling all plugins at once and turning them on individually.<\/p><p>Open your WordPress dashboard and click <strong>Plugins<\/strong> on the sidebar. Check the box on the top left corner to select all the plugins. Click the <strong>Bulk actions<\/strong> drop-down menu and select <strong>Deactivate<\/strong>. Hit <strong>Apply<\/strong>.<\/p><div class=\"wp-block-image\"><figure class=\"aligncenter size-full\"><a href=\"\/uk\/tutorials\/wp-content\/uploads\/sites\/2\/2016\/06\/wordpress-plugin-bulk-deactivation-menu.png\"><img decoding=\"async\" width=\"942\" height=\"166\" src=\"\/tutorials\/wp-content\/uploads\/sites\/2\/2016\/06\/wordpress-plugin-bulk-deactivation-menu.png\" alt=\"WordPress plugin bulk deactivation menu\" class=\"wp-image-104822\" srcset=\"https:\/\/www.hostinger.com\/uk\/tutorials\/wp-content\/uploads\/sites\/51\/2016\/06\/wordpress-plugin-bulk-deactivation-menu.png 942w, https:\/\/www.hostinger.com\/uk\/tutorials\/wp-content\/uploads\/sites\/51\/2016\/06\/wordpress-plugin-bulk-deactivation-menu-300x53.png 300w, https:\/\/www.hostinger.com\/uk\/tutorials\/wp-content\/uploads\/sites\/51\/2016\/06\/wordpress-plugin-bulk-deactivation-menu-150x26.png 150w, https:\/\/www.hostinger.com\/uk\/tutorials\/wp-content\/uploads\/sites\/51\/2016\/06\/wordpress-plugin-bulk-deactivation-menu-768x135.png 768w\" sizes=\"(max-width: 942px) 100vw, 942px\" \/><\/a><\/figure><\/div><p>For themes, you can&rsquo;t disable all of them simultaneously via the WordPress admin panel. Instead, activate each of them individually by going to <strong>Appearance <\/strong>&rarr;<strong> Themes<\/strong> on the dashboard.<\/p><p>If the database error prevents you from accessing the WordPress dashboard, temporarily deactivate all WordPress plugins by renaming the <strong>plugins <\/strong>folder via the File Manager or an FTP client.<\/p><p>For Hostinger users, go to <strong>File Manager<\/strong> &rarr; <strong>public_html<\/strong> &rarr; <strong>wp-content<\/strong>. Right-click on the <strong>plugins<\/strong> folder and select <strong>Rename<\/strong>. Enter a new name and confirm the changes.<\/p><div class=\"wp-block-image\"><figure class=\"aligncenter size-large\"><a href=\"\/uk\/tutorials\/wp-content\/uploads\/sites\/2\/2016\/06\/rename-folder-option-inhostinger-file-manager.png\"><img decoding=\"async\" width=\"1024\" height=\"122\" src=\"\/tutorials\/wp-content\/uploads\/sites\/2\/2016\/06\/rename-folder-option-inhostinger-file-manager-1024x122.png\" alt=\" The rename folder option in Hostinger File Manager\" class=\"wp-image-104825\" srcset=\"https:\/\/www.hostinger.com\/uk\/tutorials\/wp-content\/uploads\/sites\/51\/2016\/06\/rename-folder-option-inhostinger-file-manager-1024x122.png 1024w, https:\/\/www.hostinger.com\/uk\/tutorials\/wp-content\/uploads\/sites\/51\/2016\/06\/rename-folder-option-inhostinger-file-manager-300x36.png 300w, https:\/\/www.hostinger.com\/uk\/tutorials\/wp-content\/uploads\/sites\/51\/2016\/06\/rename-folder-option-inhostinger-file-manager-150x18.png 150w, https:\/\/www.hostinger.com\/uk\/tutorials\/wp-content\/uploads\/sites\/51\/2016\/06\/rename-folder-option-inhostinger-file-manager-768x92.png 768w, https:\/\/www.hostinger.com\/uk\/tutorials\/wp-content\/uploads\/sites\/51\/2016\/06\/rename-folder-option-inhostinger-file-manager.png 1452w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure><\/div><p>After renaming the folder, your website&rsquo;s back end and admin area should be accessible. Return to <strong>File Manager<\/strong> and restore the folders to their original names.<\/p><p><div><p class=\"important\"><strong>Important!<\/strong> You can disable all themes simultaneously by renaming the folder. However, unlike plugins, the default one will automatically reactivate when you revert it to the original name.<\/p><\/div>\n\n\n\n<\/p><p>All the inactive WordPress plugins should now show up in the admin dashboard. Re-enable them individually to determine the faulty ones. Then, delete the problematic plugins by clicking <strong>Delete <\/strong>underneath their names.<\/p><p>If none of the solutions work, your <a href=\"\/uk\/tutorials\/what-is-a-cms\/\">content management system<\/a> (CMS) core files might be corrupted. This means you must replace them with the default files from a fresh WordPress installation.<\/p><p><a href=\"https:\/\/wordpress.org\/download\/\" target=\"_blank\" rel=\"noreferrer noopener\">Download WordPress<\/a>, extract the package, and open its content. Delete the <strong>wp-content<\/strong> folder and the <strong>wp-config-sample.php <\/strong>file. Then, upload the remaining items into your website&rsquo;s root directory via <strong>File Manager<\/strong> or FTP.<\/p><p><div><p class=\"important\"><strong>Important!<\/strong> While you can install WordPress from scratch to restore the core files, we don&rsquo;t recommend it since it will wipe your website data.<\/p><\/div>\n\n\n\n<\/p><h3 class=\"wp-block-heading\" id=\"h-4-repair-the-database-in-wordpress\">4. Repair the Database in WordPress<\/h3><p>Another issue that might trigger &ldquo;Error Establishing a Database Connection&rdquo; in WordPress is a corrupted database. It often occurs from removing plugins or themes frequently, which can add redundant data that disrupts the tables.<\/p><p>Usually, your WordPress dashboard shows the <strong>&ldquo;One or more database tables are unavailable. The database may need to be repaired&rdquo; <\/strong>message if the database fails.<\/p><p>To run the database repair, insert the following function at the bottom of your <strong>wp-config.php<\/strong> file:<\/p><pre class=\"wp-block-preformatted\">define('WP_ALLOW_REPAIR', true);<\/pre><p>Navigate to the <strong>public_html<\/strong> folder via <strong>File Manager<\/strong>. Right-click on the <strong>wp-config.php<\/strong> file and click <strong>Edit<\/strong>. Paste the function and click the <strong>disk <\/strong>icon to save the changes.<\/p><p>Next, open a new tab in your web browser and enter <strong>http:\/\/www.your-site-domain.com\/wp-admin\/maint\/repair.php<\/strong>. You will be prompted with two database repair modes. Pick the <strong>Repair Database <\/strong>option<strong> <\/strong>and wait until the process is complete.<\/p><div class=\"wp-block-image\"><figure class=\"aligncenter size-large\"><a href=\"\/uk\/tutorials\/wp-content\/uploads\/sites\/2\/2016\/06\/wordpress-database-repair-function-screen.png\"><img decoding=\"async\" width=\"1024\" height=\"444\" src=\"\/tutorials\/wp-content\/uploads\/sites\/2\/2016\/06\/wordpress-database-repair-function-screen-1024x444.png\" alt=\"The WordPress database repair function screen\" class=\"wp-image-104826\" srcset=\"https:\/\/www.hostinger.com\/uk\/tutorials\/wp-content\/uploads\/sites\/51\/2016\/06\/wordpress-database-repair-function-screen.png 1024w, https:\/\/www.hostinger.com\/uk\/tutorials\/wp-content\/uploads\/sites\/51\/2016\/06\/wordpress-database-repair-function-screen-300x130.png 300w, https:\/\/www.hostinger.com\/uk\/tutorials\/wp-content\/uploads\/sites\/51\/2016\/06\/wordpress-database-repair-function-screen-150x65.png 150w, https:\/\/www.hostinger.com\/uk\/tutorials\/wp-content\/uploads\/sites\/51\/2016\/06\/wordpress-database-repair-function-screen-768x333.png 768w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure><\/div><p>Return to your WordPress site to see if the problem is resolved. Once it is fixed, immediately remove the repair function from the <strong>wp-config.php<\/strong> since unauthorized parties might exploit it to access your back end.<\/p><h3 class=\"wp-block-heading\" id=\"h-5-create-a-new-database\">5. Create a New Database<\/h3><p>If previous methods don&rsquo;t work, you might need to create a new MySQL database and <a href=\"https:\/\/support.hostinger.com\/en\/articles\/3989447-how-to-restore-wordpress-website-from-backups\" target=\"_blank\" rel=\"noopener\">restore the website data from a backup<\/a> since the current one might be completely corrupted.<\/p><p>The steps differ depending on your web hosting company and control panel. To do this with a Hostinger plan, start by downloading the backup.<\/p><ol class=\"wp-block-list\">\n<li>In <strong>hPanel<\/strong>, open your website management menu.<\/li>\n\n\n\n<li>From the sidebar, navigate to<strong> Files<\/strong> &rarr; <strong>Backups<\/strong>.<\/li>\n\n\n\n<li>Select <strong>Database backups<\/strong>.<\/li>\n<\/ol><div class=\"wp-block-image\"><figure class=\"aligncenter size-large\"><a href=\"\/uk\/tutorials\/wp-content\/uploads\/sites\/2\/2016\/06\/backup-selection-menu-in-hpanel.png\"><img decoding=\"async\" width=\"1024\" height=\"319\" src=\"\/tutorials\/wp-content\/uploads\/sites\/2\/2016\/06\/backup-selection-menu-in-hpanel-1024x319.png\" alt=\"Backup selection menu in hPanel\" class=\"wp-image-104827\" srcset=\"https:\/\/www.hostinger.com\/uk\/tutorials\/wp-content\/uploads\/sites\/51\/2016\/06\/backup-selection-menu-in-hpanel-1024x319.png 1024w, https:\/\/www.hostinger.com\/uk\/tutorials\/wp-content\/uploads\/sites\/51\/2016\/06\/backup-selection-menu-in-hpanel-300x93.png 300w, https:\/\/www.hostinger.com\/uk\/tutorials\/wp-content\/uploads\/sites\/51\/2016\/06\/backup-selection-menu-in-hpanel-150x47.png 150w, https:\/\/www.hostinger.com\/uk\/tutorials\/wp-content\/uploads\/sites\/51\/2016\/06\/backup-selection-menu-in-hpanel-768x239.png 768w, https:\/\/www.hostinger.com\/uk\/tutorials\/wp-content\/uploads\/sites\/51\/2016\/06\/backup-selection-menu-in-hpanel.png 1275w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure><\/div><ol start=\"4\" class=\"wp-block-list\">\n<li>Choose the faulty database from the drop-down menu and click <strong>Show Database <\/strong>to display the available backups.<\/li>\n\n\n\n<li>Select a backup date you want to restore and click <strong>Download<\/strong>.<\/li>\n\n\n\n<li>Wait until <strong>hPanel<\/strong> finishes preparing the file. Once completed, click <strong>Download Backup<\/strong>.<\/li>\n<\/ol><p>We recommend downloading multiple backups in case the latest one has errors.<\/p><p>Then, create a new database and restore the data via <strong>phpMyAdmin<\/strong>:<\/p><ol class=\"wp-block-list\">\n<li>In <strong>hPanel<\/strong>&rsquo;s website management menu, navigate to the sidebar &rarr; <strong>Databases<\/strong> &rarr; <strong>Management<\/strong>.<\/li>\n\n\n\n<li>Enter the new <strong>MySQL user<\/strong>, <strong>database username<\/strong>, and <strong>password<\/strong>. Click <strong>Create Database<\/strong>.<\/li>\n<\/ol><div class=\"wp-block-image\"><figure class=\"aligncenter size-large\"><a href=\"\/uk\/tutorials\/wp-content\/uploads\/sites\/2\/2016\/06\/database-creation-menu-in-hpanel.png\"><img decoding=\"async\" width=\"1024\" height=\"339\" src=\"\/tutorials\/wp-content\/uploads\/sites\/2\/2016\/06\/database-creation-menu-in-hpanel-1024x339.png\" alt=\"The database creation menu in hPanel\" class=\"wp-image-104828\" srcset=\"https:\/\/www.hostinger.com\/uk\/tutorials\/wp-content\/uploads\/sites\/51\/2016\/06\/database-creation-menu-in-hpanel-1024x339.png 1024w, https:\/\/www.hostinger.com\/uk\/tutorials\/wp-content\/uploads\/sites\/51\/2016\/06\/database-creation-menu-in-hpanel-300x99.png 300w, https:\/\/www.hostinger.com\/uk\/tutorials\/wp-content\/uploads\/sites\/51\/2016\/06\/database-creation-menu-in-hpanel-150x50.png 150w, https:\/\/www.hostinger.com\/uk\/tutorials\/wp-content\/uploads\/sites\/51\/2016\/06\/database-creation-menu-in-hpanel-768x254.png 768w, https:\/\/www.hostinger.com\/uk\/tutorials\/wp-content\/uploads\/sites\/51\/2016\/06\/database-creation-menu-in-hpanel.png 1284w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure><\/div><ol start=\"3\" class=\"wp-block-list\">\n<li>Scroll down and click <strong>Enter phpMyAdmin <\/strong>on the newly created database.<\/li>\n\n\n\n<li>In the database management panel, switch to the <strong>Import<\/strong> tab.<\/li>\n\n\n\n<li>Click <strong>Choose File <\/strong>and select the database backup you have downloaded. Scroll down to the bottom and click <strong>Import<\/strong>.<\/li>\n<\/ol><div class=\"wp-block-image\"><figure class=\"aligncenter size-large\"><a href=\"\/uk\/tutorials\/wp-content\/uploads\/sites\/2\/2016\/06\/phpmyadmin-database-archive-import-menu.png\"><img decoding=\"async\" width=\"1024\" height=\"369\" src=\"\/tutorials\/wp-content\/uploads\/sites\/2\/2016\/06\/phpmyadmin-database-archive-import-menu-1024x369.png\" alt=\"phpMyAdmin database archive import menu\" class=\"wp-image-104829\" srcset=\"https:\/\/www.hostinger.com\/uk\/tutorials\/wp-content\/uploads\/sites\/51\/2016\/06\/phpmyadmin-database-archive-import-menu-1024x369.png 1024w, https:\/\/www.hostinger.com\/uk\/tutorials\/wp-content\/uploads\/sites\/51\/2016\/06\/phpmyadmin-database-archive-import-menu-300x108.png 300w, https:\/\/www.hostinger.com\/uk\/tutorials\/wp-content\/uploads\/sites\/51\/2016\/06\/phpmyadmin-database-archive-import-menu-150x54.png 150w, https:\/\/www.hostinger.com\/uk\/tutorials\/wp-content\/uploads\/sites\/51\/2016\/06\/phpmyadmin-database-archive-import-menu-768x277.png 768w, https:\/\/www.hostinger.com\/uk\/tutorials\/wp-content\/uploads\/sites\/51\/2016\/06\/phpmyadmin-database-archive-import-menu.png 1496w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure><\/div><p>Lastly, connect the new MySQL database to your WordPress site by modifying the <strong>wp-config.php<\/strong> file. Open <strong>File Manager<\/strong>, navigate to the <strong>public_html <\/strong>folder, right-click on the item, and select <strong>Edit<\/strong>.<\/p><p>Enter your new MySQL user, database name, and password in the corresponding lines. Save the changes, and your WordPress dashboard should now work normally.<\/p><h3 class=\"wp-block-heading\" id=\"h-6-make-sure-your-domain-is-pointing-to-your-host-provider\">6. Make Sure Your Domain Is Pointing to Your Host Provider<\/h3><p>Switching to a new hosting provider will move your files to the new server. It might cause an error if your domain is not pointing to the correct database host, preventing the website from retrieving data.<\/p><p>To point your domain to the database host, check whether the nameservers in your hosting control panel and WHOIS match.<\/p><p>To check nameservers on Hostinger, go to <strong>hPanel <\/strong>&rarr; <strong>Websites<\/strong> &rarr; <strong>Dashboard<\/strong> &rarr; <strong>See Details<\/strong> under your web hosting plan name. Alternatively, use an online tool like <a href=\"https:\/\/dnschecker.org\/all-dns-records-of-domain.php\" target=\"_blank\" rel=\"noreferrer noopener\">dnschecker<\/a>.<\/p><div class=\"wp-block-image\"><figure class=\"aligncenter size-large\"><a href=\"\/uk\/tutorials\/wp-content\/uploads\/sites\/2\/2016\/06\/hpanel-hosting-plan-see-details-button.png\"><img decoding=\"async\" width=\"1024\" height=\"207\" src=\"\/tutorials\/wp-content\/uploads\/sites\/2\/2016\/06\/hpanel-hosting-plan-see-details-button-1024x207.png\" alt=\"The hosting plan See Details button in hPanel\" class=\"wp-image-104830\" srcset=\"https:\/\/www.hostinger.com\/uk\/tutorials\/wp-content\/uploads\/sites\/51\/2016\/06\/hpanel-hosting-plan-see-details-button-1024x207.png 1024w, https:\/\/www.hostinger.com\/uk\/tutorials\/wp-content\/uploads\/sites\/51\/2016\/06\/hpanel-hosting-plan-see-details-button-300x61.png 300w, https:\/\/www.hostinger.com\/uk\/tutorials\/wp-content\/uploads\/sites\/51\/2016\/06\/hpanel-hosting-plan-see-details-button-150x30.png 150w, https:\/\/www.hostinger.com\/uk\/tutorials\/wp-content\/uploads\/sites\/51\/2016\/06\/hpanel-hosting-plan-see-details-button-768x155.png 768w, https:\/\/www.hostinger.com\/uk\/tutorials\/wp-content\/uploads\/sites\/51\/2016\/06\/hpanel-hosting-plan-see-details-button.png 1295w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure><\/div><p>If the information matches, your domain is pointing to the correct address and should work properly. If not, enter the correct nameservers from your hosting provider on your domain registrar control panel.<\/p><p>To <a href=\"https:\/\/support.hostinger.com\/en\/articles\/1696789-how-to-change-nameservers-at-hostinger\" target=\"_blank\" rel=\"noopener\">change Hostinger domain nameservers<\/a>, navigate to <strong>hPanel <\/strong>&rarr; <strong>Domains<\/strong> &rarr; <strong>Manage<\/strong>. Under the <strong>Domain Information<\/strong> section, click <strong>Change<\/strong> next to the nameservers.<\/p><p><div><p class=\"important\"><strong>Important!<\/strong> If both your domain and website are hosted at Hostinger, the nameservers should be automatically set to ours.<\/p><\/div>\n\n\n\n<\/p><p>Alternatively, <a href=\"\/uk\/tutorials\/how-to-point-domain-to-hostinger\">point your domain name to Hostinger<\/a> via the <strong>A record<\/strong> &ndash; a type of DNS setting that assigns your domain to an IP. Note that this method only works if you are using a static address.<\/p><div class=\"wp-block-image\"><figure class=\"aligncenter size-large\"><a href=\"\/uk\/tutorials\/wp-content\/uploads\/sites\/2\/2016\/06\/a-record-value-of-a-domain-in-a-dns-lookup-tool.png\"><img decoding=\"async\" width=\"1024\" height=\"202\" src=\"\/tutorials\/wp-content\/uploads\/sites\/2\/2016\/06\/a-record-value-of-a-domain-in-a-dns-lookup-tool-1024x202.png\" alt=\"A record value of a domain name in a DNS lookup tool\" class=\"wp-image-104831\" srcset=\"https:\/\/www.hostinger.com\/uk\/tutorials\/wp-content\/uploads\/sites\/51\/2016\/06\/a-record-value-of-a-domain-in-a-dns-lookup-tool-1024x202.png 1024w, https:\/\/www.hostinger.com\/uk\/tutorials\/wp-content\/uploads\/sites\/51\/2016\/06\/a-record-value-of-a-domain-in-a-dns-lookup-tool-300x59.png 300w, https:\/\/www.hostinger.com\/uk\/tutorials\/wp-content\/uploads\/sites\/51\/2016\/06\/a-record-value-of-a-domain-in-a-dns-lookup-tool-150x30.png 150w, https:\/\/www.hostinger.com\/uk\/tutorials\/wp-content\/uploads\/sites\/51\/2016\/06\/a-record-value-of-a-domain-in-a-dns-lookup-tool-768x152.png 768w, https:\/\/www.hostinger.com\/uk\/tutorials\/wp-content\/uploads\/sites\/51\/2016\/06\/a-record-value-of-a-domain-in-a-dns-lookup-tool.png 1280w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure><\/div><p>To do this, retrieve your domain name&rsquo;s A record value using an online DNS lookup tool. Go to your hosting account and check your server&rsquo;s IP address. At Hostinger, you can find this information under the <strong>Plan details<\/strong> page.<\/p><p>Go to your registrar&rsquo;s control panel and replace the A record value with the IP address from your hosting provider. Hostinger users can find it in the <a href=\"https:\/\/support.hostinger.com\/en\/articles\/1583249-how-to-manage-dns-records-at-hostinger\" target=\"_blank\" rel=\"noopener\">DNS Zone Editor<\/a> menu.<\/p><h3 class=\"wp-block-heading\" id=\"h-7-update-wordpress-website-url\">7. Update WordPress Website URL<\/h3><p>If the database connectivity error occurs after you migrate to another host, check whether your WordPress site URL has changed. This change can prevent MySQL from connecting and sending data to the front end, resulting in an error.<\/p><p>To resolve this, <a href=\"\/uk\/tutorials\/wordpress\/how-to-change-wordpress-urls-in-mysql-database-using-phpmyadmin\">update your site URL in the MySQL database<\/a> via<strong> phpMyAdmin<\/strong>. Hostinger users can find the panel access button by going to <strong>Databases<\/strong> &rarr;<strong> Management<\/strong> in <strong>hPanel<\/strong>.<\/p><p>Select your <a href=\"\/uk\/tutorials\/wordpress-database\">WordPress database<\/a> from the sidebar and click the <strong>SQL<\/strong> tab. In the provided field, enter the following:<\/p><pre class=\"wp-block-preformatted\">UPDATE wp_options SET option_value = replace(option_value, 'http:\/\/www.old-domain.com', 'http:\/\/www.new-domain.com') WHERE option_name = 'home' OR option_name = 'siteurl';\n\nUPDATE wp_posts SET guid = replace(guid, 'http:\/\/www.old-domain.com','http:\/\/www.new-domain.com');\n\nUPDATE wp_posts SET post_content = replace(post_content, 'http:\/\/www.old-domain.com', 'http:\/\/www.new-domain.com');\n\nUPDATE wp_postmeta SET meta_value = replace(meta_value,'http:\/\/www.old-domain.com','http:\/\/www.new-domain.com');<\/pre><p>Replace <strong>http:\/\/www.old-domain.com<\/strong> with your old site URL and replace <strong>http:\/\/www.new-domain.com<\/strong> with the new one. Scroll down and click the <strong>Go<\/strong> button to run the script.<\/p><div class=\"wp-block-image\"><figure class=\"aligncenter size-large\"><a href=\"\/uk\/tutorials\/wp-content\/uploads\/sites\/2\/2016\/06\/sql-query-menu-in-phpmyadmin.png\"><img decoding=\"async\" width=\"1024\" height=\"554\" src=\"\/tutorials\/wp-content\/uploads\/sites\/2\/2016\/06\/sql-query-menu-in-phpmyadmin-1024x554.png\" alt=\"The SQL query menu in phpMyAdmin\" class=\"wp-image-104832\" srcset=\"https:\/\/www.hostinger.com\/uk\/tutorials\/wp-content\/uploads\/sites\/51\/2016\/06\/sql-query-menu-in-phpmyadmin-1024x554.png 1024w, https:\/\/www.hostinger.com\/uk\/tutorials\/wp-content\/uploads\/sites\/51\/2016\/06\/sql-query-menu-in-phpmyadmin-300x162.png 300w, https:\/\/www.hostinger.com\/uk\/tutorials\/wp-content\/uploads\/sites\/51\/2016\/06\/sql-query-menu-in-phpmyadmin-150x81.png 150w, https:\/\/www.hostinger.com\/uk\/tutorials\/wp-content\/uploads\/sites\/51\/2016\/06\/sql-query-menu-in-phpmyadmin-768x415.png 768w, https:\/\/www.hostinger.com\/uk\/tutorials\/wp-content\/uploads\/sites\/51\/2016\/06\/sql-query-menu-in-phpmyadmin.png 1446w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure><\/div><h3 class=\"wp-block-heading\" id=\"h-8-alternative-methods-to-fix-wordpress-error-establishing-a-database-connection\">8. Alternative Methods to Fix WordPress &ldquo;Error Establishing a Database Connection&rdquo;<\/h3><p>If the &ldquo;Error Establishing a Database Connection&rdquo; message persists after attempting the methods above, try the following alternatives.<\/p><p><strong>Contact the Support Team<\/strong><\/p><p>Ask your web hosting provider&rsquo;s customer support to help resolve the database issue. They have access to your website&rsquo;s back end and should be able to identify the root cause.<\/p><p>Depending on your web hosting provider, the customer support availability might differ. Hostinger&rsquo;s <a href=\"\/uk\/contacts\">Customer Success team<\/a> is available 24\/7 via live chat to help resolve your issues and answer your questions.<\/p><p>If your web host doesn&rsquo;t provide round-the-clock support, look for solutions from other sources, such as the official <a href=\"https:\/\/wordpress.org\/support\/forums\/\" target=\"_blank\" rel=\"noreferrer noopener\">WordPress forum<\/a>. Remember not to give out sensitive information, such as your database credentials, when asking questions in public forums.<\/p><p><strong>Reboot the Web Server<\/strong><\/p><p>If you host WordPress and the MySQL server on a dedicated hosting environment, reboot it to refresh the settings. Restarting will terminate background services that might cause the connectivity error.<\/p><p>Hostinger VPS users can restart the web and database server by clicking the <strong>Reboot <\/strong>button on their VPS overview page.<\/p><p>Alternatively, connect as a<strong> root<\/strong> user <a href=\"\/uk\/tutorials\/how-to-use-putty-ssh\">via an SSH client like PuTTY<\/a> and enter the restart command according to your operating system. For Linux, run:<\/p><pre class=\"wp-block-preformatted\">reboot<\/pre><p>If you don&rsquo;t use a dedicated hosting environment, ask your WordPress hosting provider for assistance since the manual restart option might be unavailable.<\/p><?xml encoding=\"utf-8\" ?><figure class=\"wp-block-image size-large\"><a href=\"\/uk\/wordpress-hosting\" target=\"_blank\" rel=\"noreferrer noopener\"><img decoding=\"async\" width=\"1024\" height=\"300\" src=\"https:\/\/www.hostinger.com\/tutorials\/wp-content\/uploads\/sites\/2\/2024\/06\/New-WP_in-text-banner-1024x300.png\" alt=\"\" class=\"wp-image-111781\" srcset=\"https:\/\/www.hostinger.com\/uk\/tutorials\/wp-content\/uploads\/sites\/51\/2024\/06\/New-WP_in-text-banner-1024x300.png 1024w, https:\/\/www.hostinger.com\/uk\/tutorials\/wp-content\/uploads\/sites\/51\/2024\/06\/New-WP_in-text-banner-300x88.png 300w, https:\/\/www.hostinger.com\/uk\/tutorials\/wp-content\/uploads\/sites\/51\/2024\/06\/New-WP_in-text-banner-150x44.png 150w, https:\/\/www.hostinger.com\/uk\/tutorials\/wp-content\/uploads\/sites\/51\/2024\/06\/New-WP_in-text-banner-768x225.png 768w, https:\/\/www.hostinger.com\/uk\/tutorials\/wp-content\/uploads\/sites\/51\/2024\/06\/New-WP_in-text-banner-1536x450.png 1536w, https:\/\/www.hostinger.com\/uk\/tutorials\/wp-content\/uploads\/sites\/51\/2024\/06\/New-WP_in-text-banner.png 2048w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure><p><strong>Restore the Latest Backup<\/strong><\/p><p>Restore both your database and website files to revert changes that might cause the errors. The easiest way is to use your web hosting control panel&rsquo;s backup feature.<\/p><p>Hostinger users can restore the latest backup in a few clicks via<strong> hPanel<\/strong>. In the website management area, navigate to the sidebar &rarr;<strong> Files<\/strong> &rarr; <strong>Backups<\/strong>. Select <strong>Restore Website<\/strong> and choose the latest date.<\/p><p>Check the confirmation box to acknowledge that the backup will overwrite your website files. Confirm by clicking <strong>Restore<\/strong>.<\/p><p>To restore your database, go to the <strong>Database Backups<\/strong> menu and follow the same steps.<\/p><h2 class=\"wp-block-heading\" id=\"h-how-to-prevent-error-establishing-a-database-connection\">How to Prevent &ldquo;Error Establishing a Database Connection&rdquo;<\/h2><p>The database issue can harm your website&rsquo;s traffic and search engine optimization. After fixing the error, apply the following best practices to prevent it from returning:<\/p><ul class=\"wp-block-list\">\n<li><strong>Enable automatic backup<\/strong>. Regularly <a href=\"\/uk\/tutorials\/backup-wordpress\">back up WordPress<\/a> and its database to ensure you have a restore point if the issue returns. It simplifies troubleshooting and prevents data loss.<\/li>\n\n\n\n<li><a href=\"\/uk\/tutorials\/wordpress-database-optimization\"><strong>Optimize your WordPress database<\/strong><\/a>. Clean up your database using a plugin like <strong>WP-Optimize<\/strong>. Having too much data will slow down your website&rsquo;s back end, potentially causing downtime and connectivity errors.<\/li>\n\n\n\n<li><strong>Install trusted themes and plugins<\/strong>. Only download plugins and themes from trusted sources like WordPress&rsquo; official library. Software from random sources might contain malware or untested code that might be incompatible with WordPress&rsquo; functionality.<\/li>\n\n\n\n<li><strong>Use a reliable web host<\/strong>. <a href=\"\/uk\/wordpress-hosting\">Host your WordPress site<\/a> on a reliable hosting provider. Hostinger ensures high uptime for your database and provides dependable support to help resolve any issue.<\/li>\n\n\n\n<li><strong>Stay up-to-date<\/strong>. Subscribe to <a href=\"\/blog\">Hostinger&rsquo;s blog<\/a> to keep up with the latest WordPress release news. These updates often explain potential issues, allowing you to take preventive measures.<\/li>\n\n\n\n<li><strong>Regular monitoring. <\/strong>Routine checking of your WordPress site and database can help quickly catch issues before they cause further damage.<\/li>\n<\/ul><h2 class=\"wp-block-heading\" id=\"h-how-to-fix-error-establishing-a-database-connection-video-tutorial\">How to Fix &ldquo;Error Establishing a Database Connection&rdquo; &ndash; Video Tutorial<a href=\"https:\/\/www.youtube.com\/@HostingerAcademy\" target=\"_blank\" rel=\"noopener\"><\/a><\/h2><p>Do you prefer following a video tutorial to solve this WordPress issue? Check out our video tutorial on how to fix the &ldquo;Error Establishing a Database Connection&rdquo; message:<\/p><figure class=\"wp-block-embed is-type-video is-provider-youtube wp-block-embed-youtube wp-embed-aspect-16-9 wp-has-aspect-ratio\"><div class=\"wp-block-embed__wrapper\">\n<iframe title=\"How to Fix Error Establishing a Database Connection\" width=\"640\" height=\"360\" src=\"https:\/\/www.youtube.com\/embed\/WsdND0nun6s?start=1&amp;feature=oembed\" frameborder=\"0\" allow=\"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share\" referrerpolicy=\"strict-origin-when-cross-origin\" allowfullscreen><\/iframe>\n<\/div><\/figure><p>\n  <div class=\"youtube-shortcode\">\n    <div class=\"row\">\n      <div class=\"col-7 col-sm-8 d-flex align-items-center\">\n        <img decoding=\"async\" class=\"channel-logo\" src=\"https:\/\/www.hostinger.com\/uk\/tutorials\/wp-content\/themes\/tutorialsthemeuplift\/public\/images\/youtube-channels\/hostinger-academy.jpg\" alt=\"youtube channel logo\">\n        <div class=\"d-flex flex-column justify-content-between\">\n          <span class=\"slogan d-none d-sm-block\">Subscribe For more educational videos!<\/span>\n          <span class=\"channel-name\">Hostinger Academy<\/span>\n                    <\/div>\n      <\/div>\n      <div class=\"col-5 col-sm-4 d-flex align-items-center justify-content-end\">\n          <a class=\"subscribe-button\" target=\"_blank\" rel=\"nofollow noopener noreferrer\" href=\"http:\/\/www.youtube.com\/channel\/UCbNIC-svDbtUOH2qsLnPQPg?sub_confirmation=1\">\n            <img decoding=\"async\" src=\"https:\/\/www.hostinger.com\/uk\/tutorials\/wp-content\/themes\/tutorialsthemeuplift\/public\/images\/icons\/youtube.svg\" alt=\"subscribe\">\n            <span>Subscribe<\/span>\n          <\/a>\n      <\/div>\n    <\/div>\n  <\/div>\n\n    \n\n\n\n<\/p><h2 class=\"wp-block-heading\" id=\"h-conclusion\">Conclusion<\/h2><p>The &ldquo;Error Establishing a Database Connection&rdquo; issue occurs when your WordPress site can&rsquo;t retrieve the requested data from the database. Its common causes include mismatched credentials, corrupted files, or server downtime.<\/p><p>In this article, we have explored some of the most common fixes for this error. First, try running a test <strong>PHP <\/strong>file to check if your database is running and the WordPress user has sufficient permissions. You can also ensure the MySQL hostname, username, and password on your hosting control panel and <strong>wp-config.php <\/strong>match.<\/p><p>If the error persists, try disabling plugins and themes with conflicting code and replacing corrupted core files with the new ones from the WordPress installation package.<\/p><p>If the above methods don&rsquo;t work, you might have a faulty database. In this case, run the WordPress repair function or create a new database using backed-up data. If you recently changed your domain, update the URL via phpMyAdmin. Also, ensure it points to the correct nameserver using a DNS checker tool.<\/p><p>To prevent the issue from returning, regularly optimize your database using a plugin like WP-Optimize. Also, make sure to host your website with a reliable provider. With Hostinger, you will get 24\/7 support and optimal website uptime.<\/p><h2 class=\"wp-block-heading\" id=\"h-error-establishing-a-database-connection-faq\">Error Establishing a Database Connection FAQ<\/h2><p>In this section, we will answer several questions about the &ldquo;Error Establishing a Database Connection&rdquo; issue.<\/p><div class=\"schema-faq wp-block-yoast-faq-block\"><div class=\"schema-faq-section\" id=\"faq-question-1709176100250\"><h3 class=\"schema-faq-question\">Why Is My WordPress Database Connection Not Working?<\/h3> <p class=\"schema-faq-answer\">If your WordPress site can&rsquo;t connect to the database, the server might be experiencing downtime. It&rsquo;s also possible the credentials in the <strong>wp-config.php<\/strong> file are incorrect. Another possible culprit is corrupted databases and core files. This often occurs due to conflicts between WordPress and plugins or themes.<\/p> <\/div> <div class=\"schema-faq-section\" id=\"faq-question-1709176124820\"><h3 class=\"schema-faq-question\">Is It Possible for a Plugin or Theme to Cause a Database Connection Error?<\/h3> <p class=\"schema-faq-answer\">Yes, untested plugins or themes can cause code conflicts that disturb the database connection. Frequently adding or removing them can also corrupt the stored data, causing the error. A potential solution is to uninstall them or create a new database if the table is corrupted.<\/p> <\/div> <div class=\"schema-faq-section\" id=\"faq-question-1709176126058\"><h3 class=\"schema-faq-question\">Can Heavy Website Traffic Lead to Database Connection Errors?<\/h3> <p class=\"schema-faq-answer\">Yes, the database host will be inaccessible if it can&rsquo;t handle the amount of user requests. In this case, your website can&rsquo;t retrieve data and content from the back end, and you will experience the error.<\/p> <\/div> <\/div>\n","protected":false},"excerpt":{"rendered":"<p>&ldquo;Error Establishing a Database Connection&rdquo; occurs when your WordPress website can&rsquo;t connect and retrieve information from the database. Its common causes include misconfigurations in the wp-config file, invalid credentials, or corrupted data. If left alone, this database problem can harm your website&rsquo;s uptime and usability. But don&rsquo;t worry &ndash; we&rsquo;re here to help you identify [&#8230;]<\/p>\n<p><a class=\"btn btn-secondary understrap-read-more-link\" href=\"\/uk\/tutorials\/wordpress-error-establishing-database-connection\">Read More&#8230;<\/a><\/p>\n","protected":false},"author":180,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"rank_math_title":"How to Fix WordPress Error Establishing A Database Connection","rank_math_description":"Learn 8 methods to solve the \u201cError Establishing a Database Connection\u201d warning in WordPress and ways to prevent it from happening","rank_math_focus_keyword":"error establishing a database connection","footnotes":""},"categories":[1],"tags":[],"class_list":["post-583","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"hreflangs":[],"_links":{"self":[{"href":"https:\/\/www.hostinger.com\/uk\/tutorials\/wp-json\/wp\/v2\/posts\/583","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.hostinger.com\/uk\/tutorials\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.hostinger.com\/uk\/tutorials\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.hostinger.com\/uk\/tutorials\/wp-json\/wp\/v2\/users\/180"}],"replies":[{"embeddable":true,"href":"https:\/\/www.hostinger.com\/uk\/tutorials\/wp-json\/wp\/v2\/comments?post=583"}],"version-history":[{"count":104,"href":"https:\/\/www.hostinger.com\/uk\/tutorials\/wp-json\/wp\/v2\/posts\/583\/revisions"}],"predecessor-version":[{"id":123072,"href":"https:\/\/www.hostinger.com\/uk\/tutorials\/wp-json\/wp\/v2\/posts\/583\/revisions\/123072"}],"wp:attachment":[{"href":"https:\/\/www.hostinger.com\/uk\/tutorials\/wp-json\/wp\/v2\/media?parent=583"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.hostinger.com\/uk\/tutorials\/wp-json\/wp\/v2\/categories?post=583"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.hostinger.com\/uk\/tutorials\/wp-json\/wp\/v2\/tags?post=583"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}