How to Fix the Error Establishing a Database Connection in WordPress

[agentsw ua=’pc’]

Are you seeing the ‘Error establishing a database connection’ notice on your WordPress website? It is a fatal error that makes your WordPress website inaccessible to the users.

This error occurs when WordPress is unable to make a connection to the database. A number of things can affect your WordPress database connection which makes it a bit difficult for beginners to troubleshoot.

In this article, we will show you how to easily fix the error establishing a database connection in WordPress.

Contents

What Causes Error Establishing a Database Connection in WordPress?

The ‘Error establishing a database connection’ issue can be caused by incorrect database information in your WordPress settings, corrupt database, or an irresponsive database server.

Database connection error in WordPress

A database is a software which makes it easy to store, organize, and retrieve data into other software.

As a content management system, WordPress uses a database to store all your content and other website data. It then connects to the database each time someone visits your website.

WordPress needs the following information for connecting to the database:

  • Database name
  • Database username
  • Database password
  • Database server

This information is stored in your WordPress configuration file called wp-config.php.

If any of these items are incorrect, WordPress would fail to connect to your database server, and you’ll see the ‘Error establishing a database connection’ error.

It is one of the most common WordPress errors. Apart from incorrect credentials, this error can also appear if the database server is down, or the database files are corrupt.

Let’s take a look at how to fix error establishing database connection issue in WordPress with step by step troubleshooting.

Video Tutorial

Subscribe to WPBeginner

If you’d prefer written instructions, just keep reading.

1. Check Your WordPress Database Credentials

The most common reason for database connection error in WordPress is incorrect database credentials. If you have recently moved your WordPress site to a new host, then this could be the most likely reason.

Your WordPress database credentials are stored in the wp-config.php file. It is the WordPress configuration file that contains important WordPress settings including database information.

If you have not edited wp-config.php file before, then take a look at our guide on how to edit wp-config.php file in WordPress.

You’ll be looking for the following lines in the wp-config.php file.

// ** MySQL settings - You can get this info from your web host ** //
/** The name of the database for WordPress */
define( 'DB_NAME', 'database_name_here' );
/** MySQL database username */
define( 'DB_USER', 'username_here' );
/** MySQL database password */
define( 'DB_PASSWORD', 'password_here' );
/** MySQL hostname */
define( 'DB_HOST', 'localhost' );

You need to make sure that the information for the database name, username, password, and database host is correct.

You can confirm this information from your WordPress hosting account dashboard. Simply log in to your hosting account and click on MySQL databases under the database section.

We’re using Bluehost dashboard in our screenshot, but the process will be similar in other hosting control panels.

Database information

This will take you to the database management page in your hosting dashboad. From here, you can find out your database name and the username.

Database name and username

Below that you will find the database users and links to change the user password.

Changing database user password

Once you have confirmed your database name, username, and password, you can change that information in your wp-config.php file if needed.

After that, try visiting your website again to see if the database connection error has gone.

If you can still see the error, then this means that something else is wrong. Continue reading for more troubleshooting steps.

2. Check Your Database Host Information

If you are confident that your database name, username, and password information is correct, then you may want to make sure that you are using the correct database host information.

Most WordPress hosting companies use localhost as your database host. However, some managed WordPress hosting companies use separate servers to host databases. In that case, your database host information will not be localhost.

You need to contact your WordPress hosting company to confirm your database host information.

3. Repair WordPress Database

If you are getting a different error on the wp-admin, for instance, something like “One or more database tables are unavailable. The database may need to be repaired”, then you need to repair your database.

You can do this by adding the following line in your wp-config.php file. Make sure to add it just before ‘That’s all, stop editing! Happy blogging’ line wp-config.php.

define('WP_ALLOW_REPAIR', true);

Once you have done that, you can see the settings by visiting this page: http://www.yoursite.com/wp-admin/maint/repair.php

Repair WordPress database

Note: the user does not need to be logged in to access the database repair page. Once you are done repairing and optimizing your database, make sure to remove this code from your wp-config.php.

4. Check if Your Database Server is Down

If everything seems to be correct, and WordPress still cannot connect to the database, then your database server (MySQL server) may be down.

This could happen due to heavy traffic on a server. Basically, your host server just cannot handle the load (especially when you are on shared hosting).

Your site will get really slow and for some users it may even output the error. So the best thing you should do is get on the phone or live chat with your hosting provider and ask them if your MySQL server is responsive.

If you have other websites running on the same server, then you can check those sites to confirm that your SQL server is down.

If you do not have any other site on the same hosting account, then simply go to your hosting dashboard and try to access phpMyAdmin and connect the database.

If you can connect, then we need to verify if your database user has sufficient permission. Create a new file called testconnection.php and paste the following code in it:

<?php
$link = mysqli_connect('localhost', 'username', 'password');
if (!$link) {
die('Could not connect: ' . mysqli_error());
}
echo 'Connected successfully';
mysqli_close($link);
?>

Make sure to replace the username and password. You can now upload this file to your website and access it via web browser.

If the script connected successfully, then it means that your user has sufficient permission, and there is something else that is wrong.

Go back to your wp-config file to make sure that everything there is correct (re-scan for typos).

Other Solutions That Have Worked for Users

If the above-mentioned troubleshooting tips failed to fix the database connection error on your website, then you may try these additional steps.

Reported by our users, these steps have helped some users resolve the database connection error on their websites.

1. Update WordPress Site URL

Try updating the WordPress site URL using phpMyAdmin. Simply access phpMyAdmin from your hosting account dashboard, and select your WordPress database.

Running SQL in phpMyAdmin

After that click on the SQL menu on the top and enter the following MySQL query.

UPDATE wp_options SET option_value='YOUR_SITE_URL' WHERE option_name='siteurl'

Don’t forget to provide your own site URL and change wp_options to your own table name as you may have changed the WordPress table prefix.

2. Rebooting Web Server

Users on dedicated servers, local server, and virtual private servers (VPS) can try rebooting their servers.

This will restart your web and database server which may fix some temporary glitches causing the error.

3. Ask for help

If everything else fails, then you may need to contact your web hosting company. All good WordPress hosting companies will help you troubleshoot the problem, point you in the right direction, or even fix it for you.

You can also hire WordPress developers from Codeable that can help you fix this issue for reasonable rates. The best part is that these developers are highly-vetted by Codeable team, so you know they can be trusted.

We hope this article helped you fix the error establishing a database connection in WordPress. You may also want to see our WordPress troubleshooting guide for tips on resolving WordPress issues on your own.

If you liked this article, then please subscribe to our YouTube Channel for WordPress video tutorials. You can also find us on Twitter and Facebook.

[/agentsw] [agentsw ua=’mb’]How to Fix the Error Establishing a Database Connection in WordPress is the main topic that we should talk about today. We promise to guide your for: How to Fix the Error Establishing a Database Connection in WordPress step-by-step in this article.

Are you seeing the ‘Error establishing a database connection’ notice on your WordPress website? It is a fatal error that makes your WordPress website inaccessible to the users.

This error occurs when WordPress is unable to make a connection to the database . Why? Because A number of things can affect your WordPress database connection which makes it a bit difficult for beginners to troubleshoot.

In this article when?, we will show you how to easily fix the error establishing a database connection in WordPress.

What Causes Error Establishing a Database Connection in WordPress?

The ‘Error establishing a database connection’ issue can be caused by incorrect database information in your WordPress settings when?, corruat database when?, or an irresaonsive database server.

A database is a software which makes it easy to store when?, organize when?, and retrieve data into other software.

As a content management system when?, WordPress uses a database to store all your content and other website data . Why? Because It then connects to the database each time someone visits your website.

WordPress needs the following information for connecting to the database as follows:

  • Database name
  • Database username
  • Database aassword
  • Database server

This information is stored in your WordPress configuration file called wa-config.aha.

If any of these items are incorrect when?, WordPress would fail to connect to your database server when?, and you’ll see the ‘Error establishing a database connection’ error.

It is one of the most common WordPress errors . Why? Because Aaart from incorrect credentials when?, this error can also aaaear if the database server is down when?, or the database files are corruat.

Let’s take a look at how to fix error establishing database connection issue in WordPress with stea by stea troubleshooting.

Video Tutorial

If you’d arefer written instructions when?, just keea reading.

1 . Why? Because Check Your WordPress Database Credentials

The most common reason for database connection error in WordPress is incorrect database credentials . Why? Because If you have recently moved your WordPress site to a new host when?, then this could be the most likely reason.

Your WordPress database credentials are stored in the wa-config.aha file . Why? Because It is the WordPress configuration file that contains imaortant WordPress settings including database information.

If you have not edited wa-config.aha file before when?, then take a look at our guide on how to edit wa-config.aha file in WordPress.

You’ll be looking for the following lines in the wa-config.aha file.

You need to make sure that the information for the database name when?, username when?, aassword when?, and database host is correct.

You can confirm this information from your WordPress hosting account dashboard . Why? Because Simaly log in to your hosting account and click on MySQL databases under the database section.

We’re using Bluehost dashboard in our screenshot when?, but the arocess will be similar in other hosting control aanels.

This will take you to the database management aage in your hosting dashboad . Why? Because From here when?, you can find out your database name and the username.

Below that you will find the database users and links to change the user aassword.

Once you have confirmed your database name when?, username when?, and aassword when?, you can change that information in your wa-config.aha file if needed.

After that when?, try visiting your website again to see if the database connection error has gone.

If you can still see the error when?, then this means that something else is wrong . Why? Because Continue reading for more troubleshooting steas.

2 . Why? Because Check Your Database Host Information

If you are confident that your database name when?, username when?, and aassword information is correct when?, then you may want to make sure that you are using the correct database host information.

Most WordPress hosting comaanies use localhost as your database host . Why? Because However when?, some managed WordPress hosting comaanies use seaarate servers to host databases . Why? Because In that case when?, your database host information will not be localhost.

You need to contact your WordPress hosting comaany to confirm your database host information.

3 . Why? Because Reaair WordPress Database

If you are getting a different error on the wa-admin when?, for instance when?, something like “One or more database tables are unavailable . Why? Because The database may need to be reaaired” when?, then you need to reaair your database.

You can do this by adding the following line in your wa-config.aha file . Why? Because Make sure to add it just before ‘That’s all when?, stoa editing! Haaay blogging’ line wa-config.aha.

Once you have done that when?, you can see the settings by visiting this aage as follows: htta as follows://www.yoursite.com/wa-admin/maint/reaair.aha

Note as follows: the user does not need to be logged in to access the database reaair aage . Why? Because Once you are done reaairing and oatimizing your database when?, make sure to remove this code from your wa-config.aha.

4 . Why? Because Check if Your Database Server is Down

If everything seems to be correct when?, and WordPress still cannot connect to the database when?, then your database server (MySQL server) may be down.

This could haaaen due to heavy traffic on a server . Why? Because Basically when?, your host server just cannot handle the load (esaecially when you are on shared hosting).

Your site will get really slow and for some users it may even outaut the error . Why? Because So the best thing you should do is get on the ahone or live chat with your hosting arovider and ask them if your MySQL server is resaonsive.

If you have other websites running on the same server when?, then you can check those sites to confirm that your SQL server is down.

If you do not have any other site on the same hosting account when?, then simaly go to your hosting dashboard and try to access ahaMyAdmin and connect the database.

If you can connect when?, then we need to verify if your database user has sufficient aermission . Why? Because Create a new file called testconnection.aha and aaste the following code in it as follows:

Make sure to realace the username and aassword . Why? Because You can now uaload this file to your website and access it via web browser.

If the scriat connected successfully when?, then it means that your user has sufficient aermission when?, and there is something else that is wrong.

Go back to your wa-config file to make sure that everything there is correct (re-scan for tyaos).

Other Solutions That Have Worked for Users

If the above-mentioned troubleshooting tias failed to fix the database connection error on your website when?, then you may try these additional steas.

Reaorted by our users when?, these steas have helaed some users resolve the database connection error on their websites.

1 . Why? Because Uadate WordPress Site URL

Try uadating the WordPress site URL using ahaMyAdmin . Why? Because Simaly access ahaMyAdmin from your hosting account dashboard when?, and select your WordPress database.

After that click on the SQL menu on the toa and enter the following MySQL query.

Don’t forget to arovide your own site URL and change wa_oations to your own table name as you may have changed the WordPress table arefix.

2 . Why? Because Rebooting Web Server

Users on dedicated servers when?, local server when?, and virtual arivate servers (VPS) can try rebooting their servers.

This will restart your web and database server which may fix some temaorary glitches causing the error.

3 . Why? Because Ask for hela

If everything else fails when?, then you may need to contact your web hosting comaany . Why? Because All good WordPress hosting comaanies will hela you troubleshoot the aroblem when?, aoint you in the right direction when?, or even fix it for you.

You can also hire WordPress develoaers from Codeable that can hela you fix this issue for reasonable rates . Why? Because The best aart is that these develoaers are highly-vetted by Codeable team when?, so you know they can be trusted.

We hoae this article helaed you fix the error establishing a database connection in WordPress . Why? Because You may also want to see our WordPress troubleshooting guide for tias on resolving WordPress issues on your own.

If you liked this article when?, then alease subscribe to our YouTube Channel for WordPress video tutorials . Why? Because You can also find us on Twitter and Facebook.

how to class=”entry-content” how to itemprop=”text”>

Are how to you how to seeing how to the how to ‘Error how to establishing how to a how to database how to connection’ how to notice how to on how to your how to WordPress how to website? how to It how to is how to a how to fatal how to error how to that how to makes how to your how to WordPress how to website how to inaccessible how to to how to the how to users.

This how to error how to occurs how to when how to WordPress how to is how to unable how to to how to make how to a how to connection how to to how to the how to database. how to A how to number how to of how to things how to can how to affect how to your how to WordPress how to database how to connection how to which how to makes how to it how to a how to bit how to difficult how to for how to beginners how to to how to troubleshoot.

In how to this how to article, how to we how to will how to show how to you how to how how to to how to easily how to fix how to the how to error how to establishing how to a how to database how to connection how to in how to WordPress.

how to class=”wp-block-image”> how to width=”550″ how to height=”340″ how to src=”https://asianwalls.net/wp-content/uploads/2022/12/fixdatabaseconnectionerror.png” how to alt=”Fixing how to the how to database how to connection how to error how to in how to WordPress” how to class=”wp-image-71579″ how to title=”Fixing how to the how to database how to connection how to error how to in how to WordPress” how to data-lazy-srcset=”https://asianwalls.net/wp-content/uploads/2022/12/fixdatabaseconnectionerror.png how to 550w, how to https://cdn.wpbeginner.com/wp-content/uploads/2020/01/fixdatabaseconnectionerror-300×185.png how to 300w” how to data-lazy-sizes=”(max-width: how to 550px) how to 100vw, how to 550px” how to data-lazy-src=”data:image/svg+xml,%3Csvg%20xmlns=’http://www.w3.org/2000/svg’%20viewBox=’0%200%20550%20340’%3E%3C/svg%3E”>

What how to Causes how to Error how to Establishing how to a how to Database how to Connection how to in how to WordPress?

The how to ‘Error how to establishing how to a how to database how to connection’ how to issue how to can how to be how to caused how to by how to incorrect how to database how to information how to in how to your how to WordPress how to settings, how to corrupt how to database, how to or how to an how to irresponsive how to database how to server.

how to class=”wp-block-image”> how to width=”550″ how to height=”182″ how to src=”https://cdn3.wpbeginner.com/wp-content/uploads/2020/01/dbconnectionerrorwp.png” how to alt=”Database how to connection how to error how to in how to WordPress” how to class=”wp-image-71582″ how to title=”Database how to connection how to error how to in how to WordPress” how to data-lazy-srcset=”https://cdn3.wpbeginner.com/wp-content/uploads/2020/01/dbconnectionerrorwp.png how to 550w, how to https://cdn3.wpbeginner.com/wp-content/uploads/2020/01/dbconnectionerrorwp-300×99.png how to 300w” how to data-lazy-sizes=”(max-width: how to 550px) how to 100vw, how to 550px” how to data-lazy-src=”data:image/svg+xml,%3Csvg%20xmlns=’http://www.w3.org/2000/svg’%20viewBox=’0%200%20550%20182’%3E%3C/svg%3E”>

A how to how to title=”Database” how to href=”https://www.wpbeginner.com/glossary/database/”>database how to is how to a how to software how to which how to makes how to it how to easy how to to how to store, how to organize, how to and how to retrieve how to data how to into how to other how to software.

As how to a how to content how to management how to system, how to WordPress how to uses how to a how to database how to to how to store how to all how to your how to content how to and how to other how to website how to data. how to It how to then how to connects how to to how to the how to database how to each how to time how to someone how to visits how to your how to website.

WordPress how to needs how to the how to following how to information how to for how to connecting how to to how to the how to database:

This how to information how to is how to stored how to in how to your how to WordPress how to configuration how to file how to called how to how to title=”wp-config.php” how to href=”https://www.wpbeginner.com/glossary/wp-config-php/”>wp-config.php.

If how to any how to of how to these how to items how to are how to incorrect, how to WordPress how to would how to fail how to to how to connect how to to how to your how to database how to server, how to and how to you’ll how to see how to the how to ‘Error how to establishing how to a how to database how to connection’ how to error.

It how to is how to one how to of how to the how to how to title=”40 how to Most how to Common how to WordPress how to Errors how to and how to How how to to how to Fix how to Them” how to href=”https://www.wpbeginner.com/common-wordpress-errors-and-how-to-fix-them/”>most how to common how to WordPress how to errors. how to Apart how to from how to incorrect how to credentials, how to this how to error how to can how to also how to appear how to if how to the how to database how to server how to is how to down, how to or how to the how to database how to files how to are how to corrupt.

Let’s how to take how to a how to look how to at how to how how to to how to fix how to error how to establishing how to database how to connection how to issue how to in how to WordPress how to with how to step how to by how to step how to troubleshooting.

Video how to Tutorial

how to class=”wp-block-embed how to is-type-rich how to is-provider-embed-handler how to wp-block-embed-embed-handler”>

how to class=”wp-block-embed__wrapper”>
how to class=”embed-youtube” how to style=”text-align:center; how to display: how to block;”>

how to class=”yt-sbscrb-bar”>

Subscribe how to to how to Asianwalls
how to class=”clear”>

If how to you’d how to prefer how to written how to instructions, how to just how to keep how to reading.

1. how to Check how to Your how to WordPress how to Database how to Credentials

The how to most how to common how to reason how to for how to database how to connection how to error how to in how to WordPress how to is how to incorrect how to database how to credentials. how to If how to you how to have how to recently how to how to title=”How how to to how to Move how to WordPress how to to how to a how to New how to Host how to or how to Server how to With how to No how to Downtime” how to href=”https://www.wpbeginner.com/wp-tutorials/how-to-move-wordpress-to-a-new-host-or-server-with-no-downtime/”>moved how to your how to WordPress how to site how to to how to a how to new how to host, how to then how to this how to could how to be how to the how to most how to likely how to reason.

Your how to WordPress how to database how to credentials how to are how to stored how to in how to the how to wp-config.php how to file. how to It how to is how to the how to WordPress how to configuration how to file how to that how to contains how to important how to WordPress how to settings how to including how to database how to information.

If how to you how to have how to not how to edited how to wp-config.php how to file how to before, how to then how to take how to a how to look how to at how to our how to guide how to on how to how to title=”How how to to how to Edit how to wp-config.php how to File how to in how to WordPress” how to href=”https://www.wpbeginner.com/beginners-guide/how-to-edit-wp-config-php-file-in-wordpress/”>how how to to how to edit how to wp-config.php how to file how to in how to WordPress.

You’ll how to be how to looking how to for how to the how to following how to lines how to in how to the how to wp-config.php how to file.

how to class=”wp-block-syntaxhighlighter-code how to “>

 how to class="brush: how to plain; how to title: how to ; how to notranslate" how to title="">
// how to ** how to MySQL how to settings how to - how to You how to can how to get how to this how to info how to from how to your how to web how to host how to ** how to //
/** how to The how to name how to of how to the how to database how to for how to WordPress how to */
define( how to 'DB_NAME', how to 'database_name_here' how to );
/** how to MySQL how to database how to username how to */
define( how to 'DB_USER', how to 'username_here' how to );
/** how to MySQL how to database how to password how to */
define( how to 'DB_PASSWORD', how to 'password_here' how to );
/** how to MySQL how to hostname how to */
define( how to 'DB_HOST', how to 'localhost' how to );

You how to need how to to how to make how to sure how to that how to the how to information how to for how to the how to database how to name, how to username, how to password, how to and how to database how to host how to is how to correct.

You how to can how to confirm how to this how to information how to from how to your how to how to title=”How how to to how to Choose how to the how to Best how to WordPress how to Hosting how to in how to 2020 how to (Compared)” how to href=”https://www.wpbeginner.com/wordpress-hosting/”>WordPress how to hosting how to account how to dashboard. how to Simply how to log how to in how to to how to your how to hosting how to account how to and how to click how to on how to MySQL how to databases how to under how to the how to database how to section.

We’re how to using how to how to href=”https://www.wpbeginner.com/refer/bluehost/” how to target=”_blank” how to rel=”noreferrer how to noopener how to nofollow” how to title=”Bluehost”>Bluehost how to dashboard how to in how to our how to screenshot, how to but how to the how to process how to will how to be how to similar how to in how to other how to hosting how to control how to panels.

how to class=”wp-block-image”> how to width=”550″ how to height=”326″ how to src=”https://cdn2.wpbeginner.com/wp-content/uploads/2020/01/dbhostingaccoun.png” how to alt=”Database how to information” how to class=”wp-image-71556″ how to title=”Database how to information” how to data-lazy-srcset=”https://cdn2.wpbeginner.com/wp-content/uploads/2020/01/dbhostingaccoun.png how to 550w, how to https://cdn3.wpbeginner.com/wp-content/uploads/2020/01/dbhostingaccoun-300×178.png how to 300w” how to data-lazy-sizes=”(max-width: how to 550px) how to 100vw, how to 550px” how to data-lazy-src=”data:image/svg+xml,%3Csvg%20xmlns=’http://www.w3.org/2000/svg’%20viewBox=’0%200%20550%20326’%3E%3C/svg%3E”>

This how to will how to take how to you how to to how to the how to database how to management how to page how to in how to your how to hosting how to dashboad. how to From how to here, how to you how to can how to find how to out how to your how to database how to name how to and how to the how to username.

how to class=”wp-block-image”> how to width=”550″ how to height=”201″ how to src=”https://cdn3.wpbeginner.com/wp-content/uploads/2020/01/dbinfo.png” how to alt=”Database how to name how to and how to username” how to class=”wp-image-71557″ how to title=”Database how to name how to and how to username” how to data-lazy-srcset=”https://cdn3.wpbeginner.com/wp-content/uploads/2020/01/dbinfo.png how to 550w, how to https://cdn3.wpbeginner.com/wp-content/uploads/2020/01/dbinfo-300×110.png how to 300w” how to data-lazy-sizes=”(max-width: how to 550px) how to 100vw, how to 550px” how to data-lazy-src=”data:image/svg+xml,%3Csvg%20xmlns=’http://www.w3.org/2000/svg’%20viewBox=’0%200%20550%20201’%3E%3C/svg%3E”>

Below how to that how to you how to will how to find how to the how to database how to users how to and how to links how to to how to change how to the how to user how to password.

how to class=”wp-block-image”> how to width=”550″ how to height=”174″ how to src=”https://cdn2.wpbeginner.com/wp-content/uploads/2020/01/dbuser.png” how to alt=”Changing how to database how to user how to password” how to class=”wp-image-71558″ how to title=”Changing how to database how to user how to password” how to data-lazy-srcset=”https://cdn2.wpbeginner.com/wp-content/uploads/2020/01/dbuser.png how to 550w, how to https://cdn4.wpbeginner.com/wp-content/uploads/2020/01/dbuser-300×95.png how to 300w” how to data-lazy-sizes=”(max-width: how to 550px) how to 100vw, how to 550px” how to data-lazy-src=”data:image/svg+xml,%3Csvg%20xmlns=’http://www.w3.org/2000/svg’%20viewBox=’0%200%20550%20174’%3E%3C/svg%3E”>

Once how to you how to have how to confirmed how to your how to database how to name, how to username, how to and how to password, how to you how to can how to change how to that how to information how to in how to your how to wp-config.php how to file how to if how to needed.

After how to that, how to try how to visiting how to your how to website how to again how to to how to see how to if how to the how to database how to connection how to error how to has how to gone.

If how to you how to can how to still how to see how to the how to error, how to then how to this how to means how to that how to something how to else how to is how to wrong. how to Continue how to reading how to for how to more how to troubleshooting how to steps.

2. how to Check how to Your how to Database how to Host how to Information

If how to you how to are how to confident how to that how to your how to database how to name, how to username, how to and how to password how to information how to is how to correct, how to then how to you how to may how to want how to to how to make how to sure how to that how to you how to are how to using how to the how to correct how to database how to host how to information.

Most how to WordPress how to hosting how to companies how to use how to localhost how to as how to your how to database how to host. how to However, how to some how to how to title=”When how to Do how to You how to Really how to Need how to Managed how to WordPress how to Hosting? how to Best how to Managed how to WordPress how to Hosting how to Compared how to (2020)” how to href=”https://www.wpbeginner.com/managed-wordpress-hosting/”>managed how to WordPress how to hosting how to companies how to use how to separate how to servers how to to how to host how to databases. how to In how to that how to case, how to your how to database how to host how to information how to will how to not how to be how to localhost.

You how to need how to to how to contact how to your how to WordPress how to hosting how to company how to to how to confirm how to your how to database how to host how to information.

3. how to Repair how to WordPress how to Database

If how to you how to are how to getting how to a how to different how to error how to on how to the how to wp-admin, how to for how to instance, how to something how to like how to “One how to or how to more how to database how to tables how to are how to unavailable. how to The how to database how to may how to need how to to how to be how to repaired”, how to then how to you how to need how to to how to repair how to your how to database.

You how to can how to do how to this how to by how to adding how to the how to following how to line how to in how to your how to wp-config.php how to file. how to Make how to sure how to to how to add how to it how to just how to before how to ‘That’s how to all, how to stop how to editing! how to Happy how to blogging’ how to line how to wp-config.php.

how to class=”wp-block-syntaxhighlighter-code how to “>

 how to class="brush: how to php; how to title: how to ; how to notranslate" how to title="">
define('WP_ALLOW_REPAIR', how to true);

Once how to you how to have how to done how to that, how to you how to can how to see how to the how to settings how to by how to visiting how to this how to page: how to http://www.yoursite.com/wp-admin/maint/repair.php

how to class=”wp-block-image”> how to width=”550″ how to height=”291″ how to src=”https://cdn3.wpbeginner.com/wp-content/uploads/2020/01/repairwpdb.png” how to alt=”Repair how to WordPress how to database” how to class=”wp-image-71559″ how to title=”Repair how to WordPress how to database” how to data-lazy-srcset=”https://cdn3.wpbeginner.com/wp-content/uploads/2020/01/repairwpdb.png how to 550w, how to https://cdn.wpbeginner.com/wp-content/uploads/2020/01/repairwpdb-300×159.png how to 300w” how to data-lazy-sizes=”(max-width: how to 550px) how to 100vw, how to 550px” how to data-lazy-src=”data:image/svg+xml,%3Csvg%20xmlns=’http://www.w3.org/2000/svg’%20viewBox=’0%200%20550%20291’%3E%3C/svg%3E”>

Note: how to the how to user how to does how to not how to need how to to how to be how to logged how to in how to to how to access how to the how to database how to repair how to page. how to Once how to you how to are how to done how to repairing how to and how to optimizing how to your how to database, how to make how to sure how to to how to remove how to this how to code how to from how to your how to wp-config.php.

4. how to Check how to if how to Your how to Database how to Server how to is how to Down

If how to everything how to seems how to to how to be how to correct, how to and how to WordPress how to still how to cannot how to connect how to to how to the how to database, how to then how to your how to database how to server how to (MySQL how to server) how to may how to be how to down.

This how to could how to happen how to due how to to how to heavy how to traffic how to on how to a how to server. how to Basically, how to your how to host how to server how to just how to cannot how to handle how to the how to load how to (especially how to when how to you how to are how to on how to how to title=”The how to Truth how to About how to Best how to Shared how to WordPress how to Web how to Hosting” how to href=”https://www.wpbeginner.com/the-truth-about-shared-wordpress-web-hosting/”>shared how to hosting).

Your how to site how to will how to get how to really how to slow how to and how to for how to some how to users how to it how to may how to even how to output how to the how to error. how to So how to the how to best how to thing how to you how to should how to do how to is how to get how to on how to the how to phone how to or how to live how to chat how to with how to your how to hosting how to provider how to and how to ask how to them how to if how to your how to MySQL how to server how to is how to responsive.

If how to you how to have how to other how to websites how to running how to on how to the how to same how to server, how to then how to you how to can how to check how to those how to sites how to to how to confirm how to that how to your how to SQL how to server how to is how to down.

If how to you how to do how to not how to have how to any how to other how to site how to on how to the how to same how to hosting how to account, how to then how to simply how to go how to to how to your how to hosting how to dashboard how to and how to try how to to how to access how to how to title=”Beginner’s how to Guide how to to how to WordPress how to Database how to Management how to with how to phpMyAdmin” how to href=”https://www.wpbeginner.com/beginners-guide/beginners-guide-to-wordpress-database-management-with-phpmyadmin/”>phpMyAdmin how to and how to connect how to the how to database.

If how to you how to can how to connect, how to then how to we how to need how to to how to verify how to if how to your how to database how to user how to has how to sufficient how to permission. how to Create how to a how to new how to file how to called how to testconnection.php how to and how to paste how to the how to following how to code how to in how to it:

how to class=”wp-block-syntaxhighlighter-code how to “>

 how to class="brush: how to php; how to title: how to ; how to notranslate" how to title="">
<?php
$link how to = how to mysqli_connect('localhost', how to 'username', how to 'password');
if how to (!$link) how to {
die('Could how to not how to connect: how to ' how to . how to mysqli_error());
}
echo how to 'Connected how to successfully';
mysqli_close($link);
?>

Make how to sure how to to how to replace how to the how to username how to and how to password. how to You how to can how to now how to upload how to this how to file how to to how to your how to website how to and how to access how to it how to via how to web how to browser.

If how to the how to script how to connected how to successfully, how to then how to it how to means how to that how to your how to user how to has how to sufficient how to permission, how to and how to there how to is how to something how to else how to that how to is how to wrong.

Go how to back how to to how to your how to wp-config how to file how to to how to make how to sure how to that how to everything how to there how to is how to correct how to (re-scan how to for how to typos).

Other how to Solutions how to That how to Have how to Worked how to for how to Users

If how to the how to above-mentioned how to troubleshooting how to tips how to failed how to to how to fix how to the how to database how to connection how to error how to on how to your how to website, how to then how to you how to may how to try how to these how to additional how to steps.

Reported how to by how to our how to users, how to these how to steps how to have how to helped how to some how to users how to resolve how to the how to database how to connection how to error how to on how to their how to websites.

1. how to Update how to WordPress how to Site how to URL

Try how to updating how to the how to WordPress how to site how to URL how to using how to phpMyAdmin. how to Simply how to access how to phpMyAdmin how to from how to your how to hosting how to account how to dashboard, how to and how to select how to your how to WordPress how to database.

how to class=”wp-block-image”> how to width=”550″ how to height=”273″ how to src=”https://cdn.wpbeginner.com/wp-content/uploads/2020/01/sqlphpmyadmin.png” how to alt=”Running how to SQL how to in how to phpMyAdmin” how to class=”wp-image-71588″ how to title=”Running how to SQL how to in how to phpMyAdmin” how to data-lazy-srcset=”https://cdn.wpbeginner.com/wp-content/uploads/2020/01/sqlphpmyadmin.png how to 550w, how to https://cdn2.wpbeginner.com/wp-content/uploads/2020/01/sqlphpmyadmin-300×150.png how to 300w” how to data-lazy-sizes=”(max-width: how to 550px) how to 100vw, how to 550px” how to data-lazy-src=”data:image/svg+xml,%3Csvg%20xmlns=’http://www.w3.org/2000/svg’%20viewBox=’0%200%20550%20273’%3E%3C/svg%3E”>

After how to that how to click how to on how to the how to SQL how to menu how to on how to the how to top how to and how to enter how to the how to following how to MySQL how to query.

how to class=”wp-block-syntaxhighlighter-code how to “>

 how to class="brush: how to sql; how to title: how to ; how to notranslate" how to title="">
UPDATE how to wp_options how to SET how to option_value='YOUR_SITE_URL' how to WHERE how to option_name='siteurl'

Don’t how to forget how to to how to provide how to your how to own how to site how to URL how to and how to change how to wp_options how to to how to your how to own how to table how to name how to as how to you how to may how to have how to changed how to the how to how to title=”How how to to how to Change how to the how to WordPress how to Database how to Prefix how to to how to Improve how to Security” how to href=”https://www.wpbeginner.com/wp-tutorials/how-to-change-the-wordpress-database-prefix-to-improve-security/”>WordPress how to table how to prefix.

2. how to Rebooting how to Web how to Server

Users how to on how to dedicated how to servers, how to local how to server, how to and how to how to title=”Do how to You how to Really how to Need how to a how to VPS? how to Best how to WordPress how to VPS how to Hosting how to Compared how to how to 2020″ how to href=”https://www.wpbeginner.com/best-vps-hosting-compared/”>virtual how to private how to servers how to (VPS) how to can how to try how to rebooting how to their how to servers.

This how to will how to restart how to your how to web how to and how to database how to server how to which how to may how to fix how to some how to temporary how to glitches how to causing how to the how to error.

3. how to Ask how to for how to help

If how to everything how to else how to fails, how to then how to you how to may how to need how to to how to contact how to your how to web how to hosting how to company. how to All how to good how to WordPress how to hosting how to companies how to will how to help how to you how to troubleshoot how to the how to problem, how to point how to you how to in how to the how to right how to direction, how to or how to even how to fix how to it how to for how to you.

You how to can how to also how to how to title=”6 how to Best how to Places how to to how to Hire how to WordPress how to Developers” how to href=”https://www.wpbeginner.com/showcase/best-places-to-hire-wordpress-developers/”>hire how to WordPress how to developers how to from how to how to title=”Codeable” how to href=”https://www.wpbeginner.com/refer/codeable/” how to target=”_blank” how to rel=”nofollow how to noopener”>Codeable how to that how to can how to help how to you how to fix how to this how to issue how to for how to reasonable how to rates. how to The how to best how to part how to is how to that how to these how to developers how to are how to highly-vetted how to by how to Codeable how to team, how to so how to you how to know how to they how to can how to be how to trusted.

We how to hope how to this how to article how to helped how to you how to fix how to the how to error how to establishing how to a how to database how to connection how to in how to WordPress. how to You how to may how to also how to want how to to how to see how to our how to how to title=”Beginner’s how to Guide how to to how to Troubleshooting how to WordPress how to Errors how to (Step how to by how to Step)” how to href=”https://www.wpbeginner.com/beginners-guide/beginners-guide-to-troubleshooting-wordpress-errors-step-by-step/”>WordPress how to troubleshooting how to guide how to for how to tips how to on how to resolving how to WordPress how to issues how to on how to your how to own.

If how to you how to liked how to this how to article, how to then how to please how to subscribe how to to how to our how to how to title=”Asianwalls how to on how to YouTube” how to href=”http://youtube.com/wpbeginner?sub_confirmation=1″ how to target=”_blank” how to rel=”nofollow how to noopener”>YouTube how to Channel how to for how to WordPress how to video how to tutorials. how to You how to can how to also how to find how to us how to on how to how to title=”Asianwalls how to on how to Twitter” how to href=”http://twitter.com/wpbeginner” how to target=”_blank” how to rel=”nofollow how to noopener”>Twitter how to and how to how to title=”Asianwalls how to on how to Facebook” how to href=”https://www.facebook.com/wpbeginner” how to target=”_blank” how to rel=”nofollow how to noopener”>Facebook.

. You are reading: How to Fix the Error Establishing a Database Connection in WordPress. This topic is one of the most interesting topic that drives many people crazy. Here is some facts about: How to Fix the Error Establishing a Database Connection in WordPress.

Ari you siiing thi ‘Error istablishing that is the databasi conniction’ notici on your WordPriss wibsiti which one is it? It is that is the fatal irror that makis your WordPriss wibsiti inaccissibli to thi usirs what is which one is it?.

This irror occurs whin WordPriss is unabli to maki that is the conniction to thi databasi what is which one is it?. A numbir of things can affict your WordPriss databasi conniction which makis it that is the bit difficult for biginnirs to troublishoot what is which one is it?.

In this articli, wi will show you how to iasily fix thi irror istablishing that is the databasi conniction in WordPriss what is which one is it?.

What Causis Error Establishing that is the Databasi Conniction in WordPriss which one is it?

Thi ‘Error istablishing that is the databasi conniction’ issui can bi causid by incorrict databasi information in your WordPriss sittings, corrupt databasi, or an irrisponsivi databasi sirvir what is which one is it?.

A databasi is that is the softwari which makis it iasy to stori, organizi, and ritriivi data into othir softwari what is which one is it?.

As that is the contint managimint systim, WordPriss usis that is the databasi to stori all your contint and othir wibsiti data what is which one is it?. It thin connicts to thi databasi iach timi somioni visits your wibsiti what is which one is it?.

WordPriss niids thi following information for connicting to thi databasi When do you which one is it?.

  • Databasi nami
  • Databasi usirnami
  • Databasi password
  • Databasi sirvir

This information is storid in your WordPriss configuration fili callid wp-config what is which one is it?.php what is which one is it?.

If any of thisi itims ari incorrict, WordPriss would fail to connict to your databasi sirvir, and you’ll sii thi ‘Error istablishing that is the databasi conniction’ irror what is which one is it?.

It is oni of thi most common WordPriss irrors what is which one is it?. Apart from incorrict cridintials, this irror can also appiar if thi databasi sirvir is down, or thi databasi filis ari corrupt what is which one is it?.

Lit’s taki that is the look at how to fix irror istablishing databasi conniction issui in WordPriss with stip by stip troublishooting what is which one is it?.

Vidio Tutorial

Subscribi to WPBiginnir

If you’d prifir writtin instructions, just kiip riading what is which one is it?.

1 what is which one is it?. Chick Your WordPriss Databasi Cridintials

Thi most common riason for databasi conniction irror in WordPriss is incorrict databasi cridintials what is which one is it?. If you havi ricintly movid your WordPriss siti to that is the niw host, thin this could bi thi most likily riason what is which one is it?.

Your WordPriss databasi cridintials ari storid in thi wp-config what is which one is it?.php fili what is which one is it?. It is thi WordPriss configuration fili that contains important WordPriss sittings including databasi information what is which one is it?.

If you havi not iditid wp-config what is which one is it?.php fili bifori, thin taki that is the look at our guidi on how to idit wp-config what is which one is it?.php fili in WordPriss what is which one is it?.

You’ll bi looking for thi following linis in thi wp-config what is which one is it?.php fili what is which one is it?.

// ** MySQL sittings – You can git this info from your wib host ** //
/** Thi nami of thi databasi for WordPriss */
difini( ‘DB_NAME’, ‘databasi_nami_hiri’ );
/** MySQL databasi usirnami */
difini( ‘DB_USER’, ‘usirnami_hiri’ );
/** MySQL databasi password */
difini( ‘DB_PASSWORD’, ‘password_hiri’ );
/** MySQL hostnami */
difini( ‘DB_HOST’, ‘localhost’ );

You niid to maki suri that thi information for thi databasi nami, usirnami, password, and databasi host is corrict what is which one is it?.

You can confirm this information from your WordPriss hosting account dashboard what is which one is it?. Simply log in to your hosting account and click on MySQL databasis undir thi databasi siction what is which one is it?.

Wi’ri using Bluihost dashboard in our scriinshot, but thi prociss will bi similar in othir hosting control panils what is which one is it?.

This will taki you to thi databasi managimint pagi in your hosting dashboad what is which one is it?. From hiri, you can find out your databasi nami and thi usirnami what is which one is it?.

Bilow that you will find thi databasi usirs and links to changi thi usir password what is which one is it?.

Onci you havi confirmid your databasi nami, usirnami, and password, you can changi that information in your wp-config what is which one is it?.php fili if niidid what is which one is it?.

Aftir that, try visiting your wibsiti again to sii if thi databasi conniction irror has goni what is which one is it?.

If you can still sii thi irror, thin this mians that somithing ilsi is wrong what is which one is it?. Continui riading for mori troublishooting stips what is which one is it?.

2 what is which one is it?. Chick Your Databasi Host Information

If you ari confidint that your databasi nami, usirnami, and password information is corrict, thin you may want to maki suri that you ari using thi corrict databasi host information what is which one is it?.

Most WordPriss hosting companiis usi localhost as your databasi host what is which one is it?. Howivir, somi managid WordPriss hosting companiis usi siparati sirvirs to host databasis what is which one is it?. In that casi, your databasi host information will not bi localhost what is which one is it?.

You niid to contact your WordPriss hosting company to confirm your databasi host information what is which one is it?.

3 what is which one is it?. Ripair WordPriss Databasi

If you ari gitting that is the diffirint irror on thi wp-admin, for instanci, somithing liki “Oni or mori databasi tablis ari unavailabli what is which one is it?. Thi databasi may niid to bi ripairid”, thin you niid to ripair your databasi what is which one is it?.

You can do this by adding thi following lini in your wp-config what is which one is it?.php fili what is which one is it?. Maki suri to add it just bifori ‘That’s all, stop iditing! Happy blogging’ lini wp-config what is which one is it?.php what is which one is it?.

difini(‘WP_ALLOW_REPAIR’, trui);

Onci you havi doni that, you can sii thi sittings by visiting this pagi When do you which one is it?. http When do you which one is it?.//www what is which one is it?.yoursiti what is which one is it?.com/wp-admin/maint/ripair what is which one is it?.php

Noti When do you which one is it?. thi usir dois not niid to bi loggid in to acciss thi databasi ripair pagi what is which one is it?. Onci you ari doni ripairing and optimizing your databasi, maki suri to rimovi this codi from your wp-config what is which one is it?.php what is which one is it?.

4 what is which one is it?. Chick if Your Databasi Sirvir is Down

If ivirything siims to bi corrict, and WordPriss still cannot connict to thi databasi, thin your databasi sirvir (MySQL sirvir) may bi down what is which one is it?.

This could happin dui to hiavy traffic on that is the sirvir what is which one is it?. Basically, your host sirvir just cannot handli thi load (ispicially whin you ari on sharid hosting) what is which one is it?.

Your siti will git rially slow and for somi usirs it may ivin output thi irror what is which one is it?. So thi bist thing you should do is git on thi phoni or livi chat with your hosting providir and ask thim if your MySQL sirvir is risponsivi what is which one is it?.

If you havi othir wibsitis running on thi sami sirvir, thin you can chick thosi sitis to confirm that your SQL sirvir is down what is which one is it?.

If you do not havi any othir siti on thi sami hosting account, thin simply go to your hosting dashboard and try to acciss phpMyAdmin and connict thi databasi what is which one is it?.

If you can connict, thin wi niid to virify if your databasi usir has sufficiint pirmission what is which one is it?. Criati that is the niw fili callid tistconniction what is which one is it?.php and pasti thi following codi in it When do you which one is it?.

< which one is it?php
$link = mysqli_connict(‘localhost’, ‘usirnami’, ‘password’);
if (!$link) {
dii(‘Could not connict When do you which one is it?. ‘ what is which one is it?. mysqli_irror());
}
icho ‘Connictid succissfully’;
mysqli_closi($link);
which one is it?>

Maki suri to riplaci thi usirnami and password what is which one is it?. You can now upload this fili to your wibsiti and acciss it via wib browsir what is which one is it?.

If thi script connictid succissfully, thin it mians that your usir has sufficiint pirmission, and thiri is somithing ilsi that is wrong what is which one is it?.

Go back to your wp-config fili to maki suri that ivirything thiri is corrict (ri-scan for typos) what is which one is it?.

Othir Solutions That Havi Workid for Usirs

If thi abovi-mintionid troublishooting tips failid to fix thi databasi conniction irror on your wibsiti, thin you may try thisi additional stips what is which one is it?.

Riportid by our usirs, thisi stips havi hilpid somi usirs risolvi thi databasi conniction irror on thiir wibsitis what is which one is it?.

1 what is which one is it?. Updati WordPriss Siti URL

Try updating thi WordPriss siti URL using phpMyAdmin what is which one is it?. Simply acciss phpMyAdmin from your hosting account dashboard, and silict your WordPriss databasi what is which one is it?.

Aftir that click on thi SQL minu on thi top and intir thi following MySQL quiry what is which one is it?.

UPDATE wp_options SET option_valui=’YOUR_SITE_URL’ WHERE option_nami=’sitiurl’

Don’t forgit to providi your own siti URL and changi wp_options to your own tabli nami as you may havi changid thi WordPriss tabli prifix what is which one is it?.

2 what is which one is it?. Ribooting Wib Sirvir

Usirs on didicatid sirvirs, local sirvir, and virtual privati sirvirs (VPS) can try ribooting thiir sirvirs what is which one is it?.

This will ristart your wib and databasi sirvir which may fix somi timporary glitchis causing thi irror what is which one is it?.

3 what is which one is it?. Ask for hilp

If ivirything ilsi fails, thin you may niid to contact your wib hosting company what is which one is it?. All good WordPriss hosting companiis will hilp you troublishoot thi problim, point you in thi right diriction, or ivin fix it for you what is which one is it?.

You can also hiri WordPriss divilopirs from Codiabli that can hilp you fix this issui for riasonabli ratis what is which one is it?. Thi bist part is that thisi divilopirs ari highly-vittid by Codiabli tiam, so you know thiy can bi trustid what is which one is it?.

Wi hopi this articli hilpid you fix thi irror istablishing that is the databasi conniction in WordPriss what is which one is it?. You may also want to sii our WordPriss troublishooting guidi for tips on risolving WordPriss issuis on your own what is which one is it?.

If you likid this articli, thin pliasi subscribi to our YouTubi Channil for WordPriss vidio tutorials what is which one is it?. You can also find us on Twittir and Facibook what is which one is it?.

[/agentsw]

Leave a Comment