WPBeginner

Beginner's Guide for WordPress

  • Blog
    • Beginners Guide
    • News
    • Opinion
    • Showcase
    • Themes
    • Tutorials
    • WordPress Plugins
  • Start Here
    • How to Start a Blog
    • Create a Website
    • Start an Online Store
    • Best Website Builder
    • Email Marketing
    • WordPress Hosting
    • Business Name Ideas
  • Deals
    • Bluehost Coupon
    • SiteGround Coupon
    • WP Engine Coupon
    • HostGator Coupon
    • Domain.com Coupon
    • Constant Contact
    • View All Deals »
  • Glossary
  • Videos
  • Products
X
☰
Beginner's Guide for WordPress / Start your WordPress Blog in minutes
Choosing the Best
WordPress Hosting
How to Easily
Install WordPress
Recommended
WordPress Plugins
View all Guides

WPBeginner» Blog» Tutorials» How to Fix the Error Establishing a Database Connection in WordPress

How to Fix the Error Establishing a Database Connection in WordPress

Last updated on January 14th, 2020 by Editorial Staff
862 Shares
Share
Tweet
Share
Pin
Free WordPress Video Tutorials on YouTube by WPBeginner
How to Fix the Error Establishing a Database Connection in WordPress

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.

Fixing the database connection error 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, 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.

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.

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.

862 Shares
Share
Tweet
Share
Pin
Popular on WPBeginner Right Now!
  • How to Fix the Error Establishing a Database Connection in WordPress

    How to Fix the Error Establishing a Database Connection in WordPress

  • How to Properly Move Your Blog from WordPress.com to WordPress.org

  • Google Analytics in WordPress

    How to Install Google Analytics in WordPress for Beginners

  • Checklist

    Checklist: 15 Things You MUST DO Before Changing WordPress Themes

About the Editorial Staff

Editorial Staff at WPBeginner is a team of WordPress experts led by Syed Balkhi. Trusted by over 1.3 million readers worldwide.

The Ultimate WordPress Toolkit

642 Comments

Leave a Reply
  1. LN says:
    Jan 10, 2021 at 9:42 am

    First I would like to say thanks for this guide!
    I am having an issue “Error establishing a database connection“ I have checked the wp-config.php and all the database information is correct. I wanted to try step 4 in this guide but I don’t really understand how. I logged in to phpMyAdmin, but not sure what the next step is. Do you have a video for that? I am not a developer just a new WP beginner.

    Reply
    • WPBeginner Support says:
      Jan 11, 2021 at 11:58 am

      You would want to go to your hosting provider’s dashboard or reach out to your hosting provider and they should be able to assist.

      Reply
  2. IK says:
    Dec 21, 2020 at 10:04 pm

    Thanks for this wonderful article. it has really helped me

    Reply
    • WPBeginner Support says:
      Dec 22, 2020 at 9:40 am

      Glad our guide was helpful :)

      Reply
  3. Daniel says:
    Nov 27, 2020 at 8:15 am

    I almost have given up after having one issue after the other, till i read this. I had this feeling that “this is it” this is the solution I have been looking for. tried it and it worked perfectly, thanks a lot.

    Reply
    • WPBeginner Support says:
      Nov 27, 2020 at 10:06 am

      Glad our guide was helpful :)

      Reply
  4. Paulo says:
    Nov 8, 2020 at 8:27 pm

    In my case, as I use digital ocean, I had to restart the DROPLET

    Reply
    • WPBeginner Support says:
      Nov 9, 2020 at 1:57 pm

      Thanks for sharing what worked for you :)

      Reply
  5. Hrutik vijay kumthekar says:
    Nov 7, 2020 at 11:57 am

    I’m getting this error when entered the URL of my site:

    There has been a critical error on your website.

    Reply
    • WPBeginner Support says:
      Nov 9, 2020 at 1:27 pm

      For that issue, you would want to take a look at our article below:

      https://www.wpbeginner.com/wp-tutorials/how-to-fix-the-wordpress-white-screen-of-death/

      Reply
  6. Arunya says:
    Nov 6, 2020 at 3:09 pm

    Thank you very much This Article really helpful

    Reply
    • WPBeginner Support says:
      Nov 9, 2020 at 11:50 am

      Glad you found our guide helpful :)

      Reply
  7. Sal says:
    Oct 15, 2020 at 11:20 am

    running out of space has done this to me a few times!

    Reply
    • WPBeginner Support says:
      Oct 16, 2020 at 9:49 am

      Thanks for sharing that should someone else run into this issue :)

      Reply
  8. jennifer mulder says:
    Oct 10, 2020 at 6:42 pm

    I am getting this error
    Warning: mysqli_real_connect(): (HY000/2002): Connection refused in /home/f5853789/public_html/wp-includes/wp-db.php on line 1635
    Connection refused

    what do I do

    Reply
    • WPBeginner Support says:
      Oct 12, 2020 at 10:50 am

      That is a different error, you would want to reach out to your hosting provider for assistance with that specific error.

      Reply
  9. Tejas Misra says:
    Oct 5, 2020 at 7:14 pm

    I am a beginner to WordPress, and I am using MAMP to install WordPress but I’m still getting this error. My credentials are correct, and none of the steps shown above appeared to work. The database is repaired too. I don’t know what to do.

    Reply
    • WPBeginner Support says:
      Oct 6, 2020 at 10:27 am

      Following our guide on setting up your site on MAMP below, you may want to ensure you added the correct database prefix.

      https://www.wpbeginner.com/wp-tutorials/how-to-install-wordpress-locally-on-mac-using-mamp/

      Reply
  10. sain says:
    Sep 27, 2020 at 1:26 pm

    Hi, I have just moved my WordPress site to a new hosting provider via ftp when this error popped up. Is there anything I’m to update after a migration? Thanks

    Reply
    • WPBeginner Support says:
      Sep 28, 2020 at 10:56 am

      For moving to a new host, you would want to take a look at our article below:

      https://www.wpbeginner.com/wp-tutorials/how-to-move-wordpress-to-a-new-host-or-server-with-no-downtime/

      Reply
  11. KWS Adams says:
    Aug 11, 2020 at 12:18 am

    Adding this line “””define(‘WP_ALLOW_REPAIR’, true);”” helped me get my site back after 14 hours of being down. Thought it was my hosts problem. Thanks for the info.

    Reply
    • WPBeginner Support says:
      Aug 11, 2020 at 10:55 am

      You’re welcome, glad the recommendation was helpful :)

      Reply
  12. Maxine says:
    Aug 7, 2020 at 4:50 am

    Thanks! Step 1 worked for me.

    Reply
    • WPBeginner Support says:
      Aug 7, 2020 at 10:17 am

      You’re welcome, glad our guide was able to help :)

      Reply
  13. Zubair Rahman says:
    Jun 26, 2020 at 4:06 pm

    How to increase the connection limit in the MySQL database? My website is intermittently giving database error as it is exceeding the max connection limit allocated on the server.

    Reply
    • WPBeginner Support says:
      Jun 30, 2020 at 10:20 am

      You would need to reach out to your hosting provider for changing that and they would be able to assist.

      Reply
  14. Agung Sudomo says:
    May 15, 2020 at 8:59 am

    I use google cloud as hosting and encounter this problem. What should I do?

    Reply
    • WPBeginner Support says:
      May 18, 2020 at 3:19 pm

      You should still be able to follow the steps in this article

      Reply
  15. Anita says:
    May 11, 2020 at 9:20 am

    Thank you so much for this! The solution for me was fixing url in sql. Thank you for the code!

    Reply
    • WPBeginner Support says:
      May 12, 2020 at 10:42 am

      You’re welcome, glad our guide could be helpful :)

      Reply
  16. Nimra afridi says:
    Apr 21, 2020 at 1:52 am

    I have installed a wordpress . i also make post but sometime it shows me that ”please install wordpress”. Why it showing me that?
    Thank you.

    Reply
    • WPBeginner Support says:
      Apr 22, 2020 at 10:38 am

      There are a few possible reasons, you may want to reach out to your hosting provider to ensure there are no hiccups on their end.

      Reply
  17. alex says:
    Apr 15, 2020 at 3:45 pm

    my website is hosted on aws and i accessed the MYSQL folder via filezila but i couldn’t find the file that contains database username , password and hostname. is there any specific name of that file?

    Reply
    • WPBeginner Support says:
      Apr 16, 2020 at 8:46 am

      The file with that information would be your wp-config.php file

      Reply
  18. Chuck Whelon says:
    Feb 29, 2020 at 5:12 pm

    Very helpful thank you.

    Reply
    • WPBeginner Support says:
      Mar 2, 2020 at 11:29 am

      You’re welcome :)

      Reply
  19. Deborah N. says:
    Nov 10, 2019 at 8:29 pm

    Thanks. Adding the repair code to my wp config file worked. I appreciate the article. It was straight forward and easy to follow.

    Reply
    • WPBeginner Support says:
      Nov 11, 2019 at 10:57 am

      You’re welcome, glad our recommendation was helpful :)

      Reply
  20. bloggeryanke says:
    Nov 9, 2019 at 5:56 pm

    your article was helpful i had changed my database password so it wasnt connecting to my blog properly but all thanks to your article the issue has been fixed

    Reply
    • WPBeginner Support says:
      Nov 11, 2019 at 10:45 am

      Glad our recommendations could help :)

      Reply
  21. Joe Marzi says:
    Oct 22, 2019 at 2:19 am

    Thank you for sharing such a nice blog.
    It will help the beginners of WordPress who are facing the problem regarding Error Establishing in the database connection. Apart from that, It gives a step by step solution so, every reader can easily solve the problem.

    Reply
    • WPBeginner Support says:
      Oct 22, 2019 at 10:14 am

      You’re welcome, glad our articles can be helpful :)

      Reply
  22. Deepak says:
    Oct 11, 2019 at 9:21 am

    Thanks for such amazing information. I really liked your article.

    Reply
    • WPBeginner Support says:
      Oct 11, 2019 at 10:57 am

      You’re welcome, glad you liked our article :)

      Reply
  23. Irwin says:
    Sep 12, 2019 at 2:49 pm

    I got this error after forcefully shutting my computer. After trying all these suggested methods and failing, I rebooted my computer and the database error was fixed.
    You should give it a try too if things go south.

    Reply
    • WPBeginner Support says:
      Sep 13, 2019 at 9:48 am

      Thanks for sharing the solution that worked for you :)

      Reply
  24. Erik says:
    Aug 20, 2019 at 11:22 pm

    Awesome! Very easy to follow and took minutes to solve.

    Reply
    • WPBeginner Support says:
      Aug 21, 2019 at 9:47 am

      Glad our guide could be helpful :)

      Reply
  25. Bob says:
    Jun 18, 2019 at 10:29 am

    Yet again you guys come to my rescue. Fixed in a couple of minutes. Well done.

    Reply
    • WPBeginner Support says:
      Jun 18, 2019 at 10:35 am

      Glad our guide could help :)

      Reply
  26. Nick Aninsley says:
    May 16, 2019 at 7:52 am

    Thank you so much for sharing this tutorial. Actually, had installed WordPress, it shows me “Error Establishing A Database Connection” and I don’t know what to do. Then I have searched on Google and I found your this article and really it is
    very helpful for me and also many people who have no idea about this things. and my site were facing many other problems and only one of them has been solved. Thank for article.

    Reply
    • WPBeginner Support says:
      May 16, 2019 at 10:58 am

      Glad our article could help :)

      Reply
  27. Emily says:
    May 14, 2019 at 11:33 pm

    I can’t back up my site or do any of what you suggest, because I cannot get into the administrative section of my blog. I can view it, as a viewer, but I have no access to anything more. I also cannot find anyway to contact people from wordpress! Help!?!!

    Reply
    • WPBeginner Support says:
      May 15, 2019 at 11:40 am

      You should be able to create a manual backup using the method here: https://www.wpbeginner.com/beginners-guide/how-to-make-a-wordpress-database-backup-manually/
      If you reach out to your hosting provider they should be able to assist with getting you access back to your site

      Reply
  28. Waqas Gulzar says:
    May 12, 2019 at 4:05 am

    Guys,

    I have fixed it now for my website

    It was due to insufficient PHP memory
    I have updated my php.ini to increase the PHP memory

    Reply
    • WPBeginner Support says:
      May 13, 2019 at 1:39 pm

      Thanks for sharing the solution that worked for you :)

      Reply
    • pushkar says:
      Jun 7, 2019 at 5:32 pm

      Hi WAQAS,
      can you please advice how you updated my php.ini to increase the PHP memory. My Site is down with the error “Error Establishing A Database Connection” and i suspect it is also to do with memory.

      Reply
      • WPBeginner Support says:
        Jun 10, 2019 at 11:33 am

        We have a guide you can follow here: https://www.wpbeginner.com/wp-tutorials/fix-wordpress-memory-exhausted-error-increase-php-memory/

        Reply
  29. ken says:
    May 10, 2019 at 10:22 pm

    I’m on BlueHost and just upgraded to WP 5.2 and got the dreaded error message:

    “Your PHP installation appears to be missing the MySQL extension which is required by WordPress.”

    I tried with PHP 5.6, 7.0 & 7.1 – all give the same response. Any ideas what I can try? My site is completely blocked by the error.

    Reply
    • WPBeginner Support says:
      May 13, 2019 at 11:58 am

      If you reach out to BlueHost they should be able to resolve that issue for you

      Reply
  30. ravendra says:
    May 10, 2019 at 4:57 am

    hello I need your help please help me my website is showing Error establishing a database connection
    how can I solve I don’t know please help me

    Reply
    • WPBeginner Support says:
      May 10, 2019 at 11:32 am

      You would want to follow the troubleshooting steps in this article for that error.

      Reply
  31. Daniel says:
    Apr 25, 2019 at 3:58 am

    I had this very same issue while using Xampp. After using the “testconection.php” file and through some further trouble shooting, I discovered that my user account was set to connect to “Any host” and by changing it to “Localhost” the problem was solved. I suspect this error came about when I updated Xampp and recreated the same named user.

    Reply
    • WPBeginner Support says:
      Apr 25, 2019 at 10:40 am

      Thanks for sharing what worked for you :)

      Reply
    • Della says:
      Sep 7, 2019 at 12:31 pm

      For my case the correct response was by Daniel.
      …I discovered that my user account was set to connect to “Any host” and by changing it to “Localhost” the problem was solved.

      Thanks so much!

      Reply
  32. jason says:
    Apr 11, 2019 at 9:49 am

    i am getting this error on my localhost

    Reply
    • WPBeginner Support says:
      Apr 11, 2019 at 11:24 am

      The methods in this article should be able to help with localhost sites as well as hosted sites.

      Reply
  33. Dana Jewel says:
    Mar 28, 2019 at 10:43 am

    Thanks for the article. Hopefully it will help.

    Reply
    • WPBeginner Support says:
      Mar 28, 2019 at 11:13 am

      You’re welcome :)

      Reply
  34. Cosme Fulanito says:
    Feb 19, 2019 at 5:01 pm

    After succeed the “Check your Web Host (MySQL Server)” test I change the host from 127.0.01 to localhost on the config.php file.

    That worked for me.

    Reply
    • WPBeginner Support says:
      Feb 20, 2019 at 10:56 am

      Thanks for sharing your solution :)

      Reply
  35. Vinay Mourya says:
    Feb 10, 2019 at 10:40 pm

    hi, it is happening to my WordPress site only sometimes and when I reload the page site starts working again please suggest me a solution, for now, I am using Cloudflare as cdn and wp rocket for caching plugin, the theme is newspaper premium.

    Reply
    • WPBeginner Support says:
      Feb 12, 2019 at 11:02 am

      If it is intermittent like that, you would want to reach out to your hosting provider and let them know and they should be able to assist.

      Reply
  36. Erick says:
    Feb 4, 2019 at 1:12 am

    This solution helped me a lot. Thanks so much.

    Reply
    • WPBeginner Support says:
      Feb 4, 2019 at 4:10 pm

      You’re welcome :)

      Reply
  37. Gee says:
    Jan 5, 2019 at 7:44 pm

    Same exact error i got “Error establishing a database connection” but not all of the sollution you mentíon helped me.

    For me the MySql services was disabled: I went to services and start the MySQL to automatic. The other thing was the ” log on ” to user was administrator and changed it to the account i created.

    Now my wordpress site is working again.

    Reply
    • WPBeginner Support says:
      Jan 8, 2019 at 10:35 am

      Thanks for sharing your solution to this issue for others :)

      Reply
  38. Umar says:
    Jan 1, 2019 at 6:28 am

    I have a weird situation is, that the error establishing a database connection is only happening to one post in my blog while other posts are not showing this issue.

    Reply
  39. rabda says:
    Dec 31, 2018 at 7:25 am

    I am receiving this error one time on 3 and not always! I do not understand why and how to solve the problem

    Reply
    • WPBeginner Support says:
      Dec 31, 2018 at 2:04 pm

      You may want to try reaching out to your hosting provider to see if their error logs have information that can help find the root of the issue.

      Reply
  40. Ryan says:
    Nov 25, 2018 at 9:04 am

    thanks so much, worked great, really appreciate how fast and to the point the video was, instead of a 7-10min extended one, boom, stright to the point!

    Reply
  41. Omar says:
    Nov 15, 2018 at 11:59 am

    I fixed it by adding “:3306” to the mysql adress “localhost” in wp-config

    Reply
  42. Bob Richardson says:
    Nov 8, 2018 at 7:21 pm

    Thanks so much for this post. Saved me lots of time troubleshooting. I had changed my database password after a web hack and forgot to change wp-config file. Your instructions are spot on.

    Reply
  43. Jelena says:
    Oct 28, 2018 at 4:11 pm

    Dude, you have just saved me TONS of nerves! Thank you SO MUCH. Best wishes and God bless!

    Reply
  44. Parker Beck says:
    Oct 21, 2018 at 10:49 am

    I fixed it by deleting the MySql database and making a new by importing the backup. I did not need a fresh instance of WordPress.

    Reply
    • Julia says:
      Feb 24, 2019 at 7:46 am

      Same here! After hours of debugging, reinstalling MySQL and WP, deleting the wordpress database was the solution. Thanks Parker!

      Reply
  45. Filipa says:
    Sep 28, 2018 at 2:46 pm

    I’m not a developer or have any background in file managing and I could follow your instructions easily. Either I’m a genius or you’re awesome! Or maybe both!

    Reply
  46. Yaser says:
    Aug 26, 2018 at 12:19 pm

    Thanks for the article.
    I had this error while setting up a local instance of WordPress running on Wamp server on windows.
    *For me, it got solved when I changed the blank password of the localhost from phpMyAdmin panel, * the password was blank so I suspect that’s the reason, or maybe changing the password updated some necessary files automatically.
    Just wanted to share this ^-^

    Reply
  47. Frenda Chu says:
    Aug 25, 2018 at 11:04 pm

    Dear sirs,
    I’m a beginner making a big mistake of using all-in-one migration to export my website to a whole package(a “.wpress” file, containing old database information inside) unless using separated database files and then restored it on my new host.
    After that my website display”Error establishing a database connection”.
    I have tried checking the config.php, but the database name is correct to my new host.
    I now understand that’ s a terrible way to migrate my web, however, I don’t have any backup. Is there any method can help save this problem?

    Reply
    • WPBeginner Support says:
      Aug 26, 2018 at 2:06 am

      Hi Frenda,

      Check your host, database name, and database password. These are the most likely culprits.

      Reply
  48. askhar says:
    Aug 9, 2018 at 10:00 pm

    Thank you very much for the guide,
    I follow step by step, and now my web is better.
    The tutorial is very useful

    Reply
  49. Jon says:
    Aug 7, 2018 at 4:17 am

    Thanks very much for the article. I’m new to WordPress, and this error was pretty disconcerting. I got the error after a simple page edit today – not even fiddling with back end files. Your advice on editing the wp config file fixed it straight away. Thanks again!

    Reply
  50. Frans Bouman says:
    Aug 3, 2018 at 2:36 pm

    Thanks immensely for the article. Although my problem wasn’t identical to the problems given, changing the hosts file managed to get me pointing at the new (unpropogated) version of the web site and replacing localhost with the ip address in wp-config took care of all the problems with pointing to the active version of the site. Now the new site is fully tested and I can shift servers safely. Well done!

    Reply
« 1 … 8 9 10

Leave a Reply Cancel reply

Thanks for choosing to leave a comment. Please keep in mind that all comments are moderated according to our comment policy, and your email address will NOT be published. Please Do NOT use keywords in the name field. Let's have a personal and meaningful conversation.

Over 1,320,000+ Readers

Get fresh content from WPBeginner

Featured WordPress Plugin
SeedProd Logo
SeedProd
Create beautiful custom landing pages - Drag & drop builder. Learn More »
How to Start a Blog How to Start a Blog
I need help with ...
Starting a
Blog
WordPress
Performance
WordPress
Security
WordPress
SEO
WordPress
Errors
Building an
Online Store
Useful WordPress Guides
    • 7 Best WordPress Backup Plugins Compared (Pros and Cons)
    • How to Fix the Error Establishing a Database Connection in WordPress
    • Why You Need a CDN for your WordPress Blog? [Infographic]
    • 30 Legit Ways to Make Money Online Blogging with WordPress
    • Self Hosted WordPress.org vs. Free WordPress.com [Infograph]
    • Free Recording: WordPress Workshop for Beginners
    • 24 Must Have WordPress Plugins for Business Websites
    • How to Properly Move Your Blog from WordPress.com to WordPress.org
    • 5 Best Contact Form Plugins for WordPress Compared
    • Which is the Best WordPress Popup Plugin? (Comparison)
    • Best WooCommerce Hosting in 2020 (Comparison)
    • How to Fix the Internal Server Error in WordPress
    • How to Install WordPress - Complete WordPress Installation Tutorial
    • Why You Should Start Building an Email List Right Away
    • How to Properly Move WordPress to a New Domain Without Losing SEO
    • How to Choose the Best WordPress Hosting for Your Website
    • How to Choose the Best Blogging Platform (Comparison)
    • WordPress Tutorials - 200+ Step by Step WordPress Tutorials
    • 5 Best WordPress Ecommerce Plugins Compared
    • 5 Best WordPress Membership Plugins (Compared)
    • 7 Best Email Marketing Services for Small Business (2020)
    • How to Choose the Best Domain Registrar (Compared)
    • The Truth About Shared WordPress Web Hosting
    • When Do You Really Need Managed WordPress Hosting?
    • 5 Best Drag and Drop WordPress Page Builders Compared
    • How to Switch from Blogger to WordPress without Losing Google Rankings
    • How to Properly Switch From Wix to WordPress (Step by Step)
    • How to Properly Move from Weebly to WordPress (Step by Step)
    • Do You Really Need a VPS? Best WordPress VPS Hosting Compared
    • How to Properly Move from Squarespace to WordPress
    • How to Register a Domain Name (+ tip to get it for FREE)
    • HostGator Review - An Honest Look at Speed & Uptime (2020)
    • SiteGround Reviews from 4196 Users & Our Experts (2020)
    • Bluehost Review from Real Users + Performance Stats (2020)
    • How Much Does It Really Cost to Build a WordPress Website?
    • How to Create an Email Newsletter the RIGHT WAY (Step by Step)
    • Free Business Name Generator (A.I Powered)
    • How to Create a Free Business Email Address in 5 Minutes (Step by Step)
    • How to Install Google Analytics in WordPress for Beginners
    • How to Move WordPress to a New Host or Server With No Downtime
    • Why is WordPress Free? What are the Costs? What is the Catch?
    • How to Make a Website in 2020 – Step by Step Guide
Deals & Coupons (view all)
AliDropship Coupon Code
AliDropship Coupon
Get 15% off on AliDropship WordPress and WooCommerce dropshipping plugin.
Beaver Builder Coupon Code
Beaver Builder Coupon
Get the best possible price on this easy drag-and-drop page builder plugin. From just $99 in 2020.
Featured In
About WPBeginner®

WPBeginner is a free WordPress resource site for Beginners. WPBeginner was founded in July 2009 by Syed Balkhi. The main goal of this site is to provide quality tips, tricks, hacks, and other WordPress resources that allows WordPress beginners to improve their site(s).
Join our team: We are Hiring!

Site Links
  • About Us
  • Contact Us
  • FTC Disclosure
  • Privacy Policy
  • Terms of Service
  • Free Blog Setup
  • Free Business Tools
Our Sites
  • OptinMonster
  • MonsterInsights
  • WPForms
  • SeedProd
  • Nameboy
  • RafflePress
  • Smash Balloon

Copyright © 2009 - 2021 WPBeginner LLC. All Rights Reserved. WPBeginner® is a registered trademark.

Managed by Awesome Motive | WordPress hosting by SiteGround | WordPress CDN by MaxCDN | WordPress Security by Sucuri.