Trusted WordPress tutorials, when you need them most.
Beginner’s Guide to WordPress
WPB Cup
25 Million+
Websites using our plugins
16+
Years of WordPress experience
3000+
WordPress tutorials
by experts

Wie man den Fehler beim Herstellen einer Datenbankverbindung in WordPress behebt

Sehen Sie die Meldung „Fehler beim Herstellen einer Datenbankverbindung“ in WordPress?

Dies ist ein schwerwiegender Fehler, der Ihre Website für die Benutzer unzugänglich macht. Er tritt auf, wenn WordPress nicht in der Lage ist, eine Verbindung mit der Datenbank herzustellen. Da mehrere Faktoren diese Verbindung beeinträchtigen können, kann die Fehlerbehebung für Anfänger etwas schwierig sein.

In diesem Artikel zeigen wir Ihnen, wie Sie das Problem „Fehler beim Herstellen einer Datenbankverbindung“ auf Ihrer WordPress-Website Schritt für Schritt beheben können.

Fix the Error Establishing a Database Connection in WordPress

Was ist die Ursache für den Fehler beim Herstellen einer Datenbankverbindung in WordPress?

Eine Datenbank ist eine Software, die das Speichern, Organisieren und Abrufen von Daten aus anderer Software erleichtert.

Als Content-Management-System verwendet WordPress eine Datenbank, in der alle Inhalte und andere Daten Ihrer Website gespeichert werden. Jedes Mal, wenn jemand Ihre Website besucht, stellt es eine Verbindung zur Datenbank her.

WordPress benötigt die folgenden Informationen für die Verbindung zur Datenbank:

  • Ihr Datenbankname
  • Datenbank-Benutzername und Passwort
  • Datenbank-Server

Diese Informationen werden in Ihrer WordPress-Konfigurationsdatei gespeichert, die wp-config.php heißt.

Wenn eine dieser Informationen nicht korrekt ist, kann WordPress keine Verbindung zu Ihrem Datenbankserver herstellen, und Sie erhalten die Fehlermeldung „Fehler beim Herstellen einer Datenbankverbindung“.

Database connection error in WordPress

Dies ist einer der häufigsten WordPress-Fehler. Abgesehen von falschen Anmeldeinformationen kann dieser Fehler auch auftreten, wenn der Datenbankserver ausgefallen ist oder die Datenbankdateien beschädigt sind.

Schauen wir uns nun an, wie man das Problem „Fehler beim Herstellen einer Datenbankverbindung“ in WordPress mit einer schrittweisen Fehlerbehebung beheben kann.

1. Überprüfen Sie Ihre WordPress-Datenbank-Zugangsdaten

Der häufigste Grund für den Datenbankverbindungsfehler sind falsche Anmeldedaten. Wenn Sie Ihre WordPress-Website vor kurzem auf einen neuen Host verschoben haben, ist dies wahrscheinlich das Problem.

Die Zugangsdaten für Ihre WordPress-Datenbank sind in der Datei wp-config.php gespeichert. Es handelt sich um die WordPress-Konfigurationsdatei, die wichtige Einstellungen, einschließlich Datenbankinformationen, enthält.

Wenn Sie die Datei wp-config.php noch nie bearbeitet haben, lesen Sie bitte unsere Anleitung für Anfänger zum Bearbeiten der Datei wp-config.php.

Sie suchen in der Datei wp-config.php nach den folgenden Zeilen:

// ** 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' );

Hier müssen Sie sicherstellen, dass die Informationen für den Datenbanknamen, den Benutzernamen, das Passwort und den Datenbankhost korrekt sind.

Sie können diese Informationen über das Dashboard Ihres WordPress-Hosting-Kontos bestätigen. In diesem Tutorial verwenden wir Bluehost, aber der Vorgang ist auch bei anderen Hosting-Panels ähnlich.

Klicken Sie nach dem Einloggen auf die Registerkarte „Website“ in der linken Spalte und wechseln Sie dann auf die Registerkarte „Erweitert“. Scrollen Sie dann nach unten zum Abschnitt „Datenbank“ und klicken Sie auf die Schaltfläche „Verwalten“ daneben.

Click the Manage button next to the Database section

Dadurch wird die Seite MySQL-Datenbanken in cPanel in einem neuen Fenster geöffnet.

Hier finden Sie Ihren Datenbanknamen und Ihren Benutzernamen im Abschnitt „Aktuelle Datenbank“. Denken Sie daran, diese Angaben zu kopieren und in einen Notizblock einzufügen, damit Sie sie der wp-config-Datei hinzufügen können.

Find your database name and username in the Current Databases section

Blättern Sie dann zum Abschnitt „Aktuelle Benutzer“, wo Sie auf den Link „Passwort ändern“ neben Ihrem Datenbanknamen klicken können.

Daraufhin wird ein neuer Bildschirm angezeigt, in dem Sie das Datenbankpasswort nach Ihren Wünschen ändern können.

Change your database password

Sobald Sie alle Angaben zu Ihrer Datenbank bestätigt haben, können Sie diese Informationen bei Bedarf in Ihrer wp-config.php-Datei ändern.

Versuchen Sie danach, Ihre Website erneut zu besuchen, um zu sehen, ob der Datenbankverbindungsfehler verschwunden ist.

Wenn Sie den Fehler immer noch sehen, bedeutet dies, dass etwas anderes nicht stimmt.

2. Prüfen Sie Ihre Datenbank-Host-Informationen

Wenn Sie sicher sind, dass Ihr Datenbankname, Ihr Benutzername und Ihr Kennwort korrekt sind, sollten Sie sich vergewissern, dass Sie die richtigen Datenbank-Hostinformationen verwenden.

Die meisten WordPress-Hosting-Unternehmen verwenden localhost als Datenbank-Host. Einige Managed-WordPress-Hosting-Unternehmen verwenden jedoch separate Server zum Hosten von Datenbanken. In diesem Fall ist Ihr Datenbank-Host nicht localhost.

Das bedeutet, dass Sie sich mit Ihrem WordPress-Hosting-Unternehmen in Verbindung setzen müssen, um diese Angaben zu bestätigen.

3. WordPress-Datenbank reparieren

Möglicherweise erhalten Sie jetzt eine andere Fehlermeldung im wp-admin Dashboard wie „Eine oder mehrere Datenbanktabellen sind nicht verfügbar“ oder „Die Datenbank muss möglicherweise repariert werden“. In diesem Fall müssen Sie Ihre Datenbank reparieren.

Fügen Sie dazu die folgende Zeile in Ihre wp-config.php-Datei ein. Fügen Sie sie direkt vor der Zeile ‚That’s all, stop editing! Viel Spaß beim Bloggen“:

define('WP_ALLOW_REPAIR', true);

Sobald Sie dies getan haben, können Sie die Einstellungen auf dieser Seite sehen: http://www.yoursite.com/wp-admin/maint/repair.php. Achten Sie nur darauf, dass Sie yoursite.com durch Ihren eigenen Domänennamen ersetzen.

Hier müssen Sie auf die Schaltfläche „Datenbank reparieren“ klicken, um den Vorgang zu starten.

Repair WordPress database

Hinweis: Der Benutzer muss nicht angemeldet sein, um auf die Seite zur Reparatur der Datenbank zugreifen zu können. Sobald Sie mit der Reparatur und Optimierung Ihrer Datenbank fertig sind, stellen Sie sicher, dass Sie diese Codezeile aus Ihrer wp-config.php entfernen.

Wenn Sie jedoch keinen Code zu Ihrer Website hinzufügen möchten, können Sie Ihre Datenbank auch über das cPanel Ihres Hosting-Kontos reparieren.

Gehen Sie zu Ihrem Hosting-Account und öffnen Sie dort in der linken Spalte die Seite „Websites“. Wechseln Sie dann auf die Registerkarte „Erweitert“ und klicken Sie im Bereich „Datenbank“ auf die Schaltfläche „Verwalten“.

Click the Manage button next to the Database section

Dadurch wird cPanel in einer neuen Registerkarte geöffnet. Scrollen Sie hier zum Abschnitt „Datenbanken ändern“ und wählen Sie den Namen Ihrer Datenbank aus dem Dropdown-Menü „Datenbank reparieren“.

Klicken Sie dann einfach auf die Schaltfläche „Datenbank reparieren“, um den Vorgang zu starten.

Click the Repair database button

Das Hosting-Panel wird nun automatisch Ihre Datenbank für Sie reparieren.

Sobald der Vorgang abgeschlossen ist, wird auch eine Erfolgsmeldung angezeigt.

Database repair success message

Sie können nun Ihre WordPress-Website besuchen, um zu sehen, ob der Fehler behoben wurde oder nicht.

4. Prüfen Sie, ob Ihr Datenbankserver ausgefallen ist

Wenn alles korrekt zu sein scheint und WordPress immer noch keine Verbindung zur Datenbank herstellen kann, ist Ihr Datenbankserver(MySQL-Server) möglicherweise ausgefallen.

Dies kann aufgrund von starkem Datenverkehr auf einem Server passieren. Ihr Host-Server kann die Last einfach nicht bewältigen (vor allem, wenn Sie ein Shared Hosting nutzen).

Dies führt dazu, dass Ihre Website langsam wird und bei einigen Benutzern sogar einen Fehler ausgibt. In diesem Fall sollten Sie mit Ihrem Hosting-Provider telefonieren oder live chatten und ihn fragen, ob Ihr MySQL-Server ansprechbar ist.

Wenn Sie außerdem andere Websites auf demselben Server betreiben, können Sie diese Websites überprüfen, um festzustellen, ob Ihr SQL-Server ausgefallen ist.

Wenn Sie keine andere Website auf demselben Hosting-Account haben, gehen Sie einfach auf Ihr Hosting-Dashboard und wechseln Sie auf die Registerkarte „Erweitert“.

Klicken Sie anschließend auf die Schaltfläche „Verwalten“ neben dem phpMyAdmin-Bereich.

Click the Manage button next to the PHPMyAdmin option

Dadurch wird phpMyAdmin in einem neuen Fenster geöffnet, in dem Sie oben auf die Option „Datenbank“ klicken müssen.

Klicken Sie dann auf den Namen Ihrer Datenbank, um deren Einstellungen aufzurufen. Wenn Sie dies tun können, ist es an der Zeit zu prüfen, ob Ihr Datenbankbenutzer über ausreichende Berechtigungen verfügt.

Connect PHPMyAdmin with your database

Dazu müssen Sie eine neue Datei mit dem Namen testconnection.php erstellen und den folgenden Code darin einfügen:

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

Achten Sie beim Einfügen des Codes darauf, dass Sie den Benutzernamen und das Passwort durch Ihren eigenen ersetzen. Sie können diese Datei nun auf Ihre Website hochladen und über einen Webbrowser darauf zugreifen.

Wenn das Skript erfolgreich verbunden wurde, bedeutet dies, dass Ihr Benutzer über ausreichende Berechtigungen verfügt und der Fehler durch etwas anderes verursacht wird.

Nun müssen Sie zu Ihrer wp-config-Datei zurückkehren und sie überprüfen, um sicherzustellen, dass alle Angaben korrekt und ohne Tippfehler sind.

Zusätzliche Lösungen, die sich für Benutzer bewährt haben

Wenn die oben genannten Tipps zur Fehlerbehebung nicht ausreichen, um den Datenbankverbindungsfehler auf Ihrer Website zu beheben, können Sie diese zusätzlichen Schritte versuchen.

Wie von unseren Benutzern berichtet, haben diese Schritte einigen von ihnen geholfen, den Datenbankverbindungsfehler auf ihren Websites zu beheben.

1. Aktualisieren Sie die URL der WordPress-Website

Sie können versuchen, die URL der WordPress-Website mit phpMyAdmin im cPanel zu aktualisieren.

Rufen Sie einfach phpMyAdmin über das Dashboard Ihres Hosting-Accounts auf und wählen Sie Ihre WordPress-Datenbank aus der Liste aus.

Wechseln Sie dann oben in das SQL-Menü und geben Sie die folgende MySQL-Abfrage ein:

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

Sie sollte folgendermaßen aussehen:

Change site URL

Vergessen Sie nicht, die URL Ihrer eigenen Website anzugeben und wp_options in Ihren eigenen Tabellennamen zu ändern, da Sie möglicherweise das WordPress-Tabellenpräfix geändert haben.

2. Neustart des Webservers

Benutzer von dedizierten Servern, lokalen Servern und virtuellen privaten Servern (VPS ) können versuchen, ihre Server neu zu starten.

Dadurch wird Ihr Web- und Datenbankserver neu gestartet, was möglicherweise einige vorübergehende Störungen behebt, die den Fehler verursachen.

3. Um Hilfe bitten

Wenn alles andere fehlschlägt, sollten Sie sich an Ihr Webhosting-Unternehmen wenden. Alle guten WordPress-Hosting-Unternehmen werden Ihnen bei der Fehlersuche helfen, Ihnen die richtige Richtung weisen oder das Problem sogar für Sie beheben.

Sie können auch WordPress Entwickler über eine Plattform wie WPBeginner Pro Services anheuern, um dieses Problem zu vernünftigen Preisen zu lösen. Wir haben ein engagiertes Team von erfahrenen Entwicklern, denen Sie vertrauen können, um alle Ihre WordPress-Probleme zu lösen.

WPBeginner Pro Services

Außerdem können Sie den Dienst für die Wartung Ihrer Website, die Reparatur von gehackten Websites, die Geschwindigkeitsoptimierung, den Wiederaufbau von Websites und die SEO-Optimierung nutzen.

Wir hoffen, dass dieser Artikel Ihnen geholfen hat, das Problem „Fehler beim Herstellen einer Datenbankverbindung“ in WordPress zu beheben. Vielleicht möchten Sie auch unseren WordPress-Leitfaden zur Fehlerbehebung lesen, um Tipps zur Behebung von WordPress-Problemen zu erhalten, oder unsere Expertenauswahl der besten Tools für WordPress-Freiberufler und Entwickler.

Wenn Ihnen dieser Artikel gefallen hat, dann abonnieren Sie bitte unseren YouTube-Kanal für WordPress-Videotutorials. Sie können uns auch auf Twitter und Facebook finden.

Offenlegung: Unsere Inhalte werden von unseren Lesern unterstützt. Das bedeutet, dass wir möglicherweise eine Provision verdienen, wenn Sie auf einige unserer Links klicken. Mehr dazu erfahren Sie unter Wie WPBeginner finanziert wird , warum das wichtig ist und wie Sie uns unterstützen können. Hier finden Sie unseren redaktionellen Prozess .

Avatar

Editorial Staff at WPBeginner is a team of WordPress experts led by Syed Balkhi with over 16 years of experience in WordPress, Web Hosting, eCommerce, SEO, and Marketing. Started in 2009, WPBeginner is now the largest free WordPress resource site in the industry and is often referred to as the Wikipedia for WordPress.

Das ultimative WordPress Toolkit

Erhalte KOSTENLOSEN Zugang zu unserem Toolkit - eine Sammlung von WordPress-bezogenen Produkten und Ressourcen, die jeder Profi haben sollte!

Reader Interactions

661 KommentareEine Antwort hinterlassen

  1. Syed Balkhi says

    Hey WPBeginner readers,
    Did you know you can win exciting prizes by commenting on WPBeginner?
    Every month, our top blog commenters will win HUGE rewards, including premium WordPress plugin licenses and cash prizes.
    You can get more details about the contest from here.
    Start sharing your thoughts below to stand a chance to win!

    • Mark Larson says

      You’re so helpful! All my writing was saved! Yes, I need to do a backup… I did one! Thanks so much, this is just the resource I needed. Luckily Google pulled it right up.

  2. Michael Simoni says

    I have a test wordpress installation on my home computer running on fedora. I moved/reinstalled the computer with a recent copy of fedora. I restored the database and the wordpress installation. Everything should have been fine except I had the „cannot connect to the database“ error. I have had this wordpress installation for a long time. Turns out that when I moved to the new server I also got a new my.cnf. Now I checked it and made everything the same but for some reason i did not add the following line in /etc/my.cnf. Maybe i just wanted to see what would happen. hmmm…what does this button do…..
    # Default to using old password format for compatibility with mysql 3.x
    # clients (those using the mysqlclient10 compatibility package).
    old_passwords=1
    After I added that line, the database connection problem was fixed.
    So I need to drop that user and recreate it with the new password format.
    Note I also have
    skip-networking
    in /etc/my.cnf and….it works. That keeps mysql off the network, including 127.0.0.1. It’s just one less entry point for the mischief-makers.

  3. Matt says

    I had a database-connection-error on a client’s site and could access the database via PHPMyAdmin but running the testconnect.php file suggested above came up with a response unlisted in this article:

    „PHP Warning: mysql_connect(): No connection could be made because the target machine actively refused it.“

    I got in touch with Fasthosts who my clients were with and it turned out that they had issues integrating PHP5.4 „and the only fix is to reset the MySQL database user password.“

    So if you’re in that boat, then you may be able to fix it by accessing the database via PHPMyAdmin and running the query:

    SET SESSION old_passwords = 0;
    SET PASSWORD = PASSWORD(‚databasepasswordgoeshere‘);

    !! IMPORTANT NOTE !! : make sure you get ‚databasepasswordgoeshere‘ correct otherwise you’ll be resetting your db password to something new rather than the same password and it could break your site even further!

  4. Terry says

    I must be really dumb! i understand a little of wordpress but this all sounds way out of my leage.

    I have tried to do exactly what you have said and this is what I get

    Warning: Cannot modify header information – headers already sent by (output started at /customers/8/a/3/chigwelltkd.com/httpd.www/wordpress/wp-config.php:2) in /customers/8/a/3/chigwelltkd.com/httpd.www/wordpress/wp-includes/functions.php on line 2801
    Error establishing a database connection.

    I have no idea what to do next!!!

    Not only have i lost the site from the web but I know cannot get in to wordpress admin.

    IS THERE ANY HOPE!!!!!

  5. Sumi Ghosh says

    Hi,

    Recently i uploaded a theme to the wordpress site, i have also uploaded the local database. I have modified my wp-config file too. Still i am getting error database connection error. When i opened my wp-admin it redirecting to wp-login.

    Can i know what might be the problem?

    • WPBeginner Support says

      We think its normal behavior for wordpress to redirect you to wp-login.php when you try to access wp-admin directory. Can you please explain further? have you checked your wp-config.php file? does it have your live site’s database information?

      Admin

  6. Aliesha says

    I had 4 sites give a 127.0.0.1 „Cannot connect to server“ message & I also had no access to admin. I went through troubleshooting, & nothing helped. So, I contacted my web-hosting service, Bluehost, to inquire whether the MySQL server was responsive. The tech told me to login to my control panel’s File Manager, select „Show hidden files,“ and then to go inside my root directory for each domain & rename my .htaccess file to .htaccess.old . He said he guessed that a plugin added code to my .htaccess file, causing my wp-admin to redirect to an IP address. It worked. :)

  7. Erik de Vries says

    Just got this error on my own website. wp-config.php was allright. PhpMyAdmin could load the database. When trying to open the wp_options table PhpMyAdmin said the table must be repaired. Using the repair function in PhpMyAdmin fixed the table, reporting one row had been removed (not saying which one). No clue as to what caused this.
    Thanks for the article, helped me debug the error.

  8. Ben says

    Just got this problem, checked db through host cPanel and admin user seems to have been removed from database assuming that is why wp cannot connect. Problem is my ftp also seems to have been knocked out so i am unable to apply any solutions! sub-domain seems to still be working. It’s difficult to imagine this as being anything other than malicious!

  9. Zimbrul says

    I just got this problem with one of my sites and fixing the database from wp-config.php did not work. I fixed it by upgrading to WordPress 3.6.1 in cPanel (Softaculous).

  10. Ike says

    Today, for some reason my site is facing the database connection issue.
    • Confirmed my database access is working via testconnection.php.
    • Changed the salt keys with new ones.
    • Defined the proper site URLs to ‚WP_HOME‘ and ‚WP_SITEURL‘
    • No issue with server slowness as my other websites in other root directories are working.

    I’m guessing it may be a plugin recently added?
    How do you properly uninstall a plugin if you can’t pull up both wordpress root and wp-admin directories in the browser?

    Thanks in advanced.

  11. Anudeep says

    Thanks a lot for such a good article!
    My problem was a bit different. I had this issue because of ‚clicky analytics‘ plugin.
    I almost went mad as i didnt have any idea of what the problem could be. Finally after lot of trial and error i figured out that it was a plugin interference.

  12. Naman Agrawal says

    Huh! sir you deserve an award.
    It just worked for me. I was having this problem from last one month and you just served with this.
    Thank you very much :)

  13. Roeland Sanctorum says

    Problem occured when requesting new password and didn’t realise this was going to create a db problem. Fortunately I found your comments and guidelines. Problem solved in 3 minutes.
    Thanks again (now I’ve subscribed to your weekly email)

  14. Tamela says

    My problem happened when I moved the site to a new hosting. I’d altered the config file to match my new database, username & password. But nothing worked.

    Your tip about checking the WP-admin page did the trick. It told me something was wrong with the username. I went into c-panel and realized I hadn’t tied the user to the database. Two seconds later, all was good!

    You potentially saved me hours of testing the wrong things! Thanks!

  15. Stu Farrimond says

    I want to give you a big kiss.

    VERY useful.

    However, my issue seemed a little odd – and it might help someone else:

    This morning our domain produced error:

    Fatal error: Allowed memory size of 41943040 bytes exhausted (tried to allocate 30720 bytes) in /home/gurumaga/public_html/wp-admin/includes/class-wp-list-table.php on line 384

    I tried to increase PHP memory allocation.

    Added to wp-settings (in root folder):
    define(‚WP_MAX_MEMORY_LIMIT‘, ‚256M‘);
    resulted in:
    ‚Error establishing a database connection‘

    Removed line and added lower limit:
    define(‚WP_MEMORY_LIMIT‘, ’64M‘);
    resulted in:
    ‚Error establishing a database connection‘

    Removed all changes in wp-settings.php now as original.
    ‚Error establishing a database connection‘ persisted (for 5 – 10 mins)

    Before reverting to the original error:
    Fatal error: Allowed memory size of 41943040 bytes exhausted (tried to allocate 30720 bytes) in /home/gurumaga/public_html/wp-admin/includes/class-wp-list-table.php on line 384

    I increased the PHP memory limit to: define(‚WP_MEMORY_LIMIT‘, ’64M‘); again
    Then ran the database repair as you advised.

    Although no database errors were identified, the site is now back up and running.

    Odd – I’m not sure if you or anyone else can make sense of it??

  16. Michael says

    Embarrassed… I tried everything in this blog and was double checking everything…
    It never occurred to me that I’d typo’ed when entering the password.

    Doh! So, here’s a +! for double checking the basics ;)

  17. Shaqinah says

    Hi, I made the mistake of changing the home url, initially it was http://shaneynayguns.com/wordpress and the site url was: http://shaneynayguns.com/wordpress too. I then changed the site url to http://shaneynayguns.com (thinking that that will make my site go live, as you can tell I’m an absolute idiot at this). Nothing happened, so genius here, changed the home url to shaneynayguns.com. That’s when things start to go awry: I couldn’t log in to wp-admin anymore and going to .com/wordpress redirects me to an error page. (shaneynayguns.com remain unchanged and directs to a landing page) I then went on to a forum and followed the exact instructions which were:
    1. go to phpmyadmin
    2. go to the correct database
    3. browse wp_option
    4. edit site url (I changed it to .com/wordpress)
    Apparently based on everyone’s comments, it worked for all of them… except me! shaneynayguns.com/wordpress now redirects to a page with „error establishing a database connection“! It’s driving me mental! I was hoping if any of you could help me with this. As is obvious, I have not a clue when it comes to web jargon so I would really appreciate a simplified solution. Yes I’m an idiot, and I terribly need help! (F.Y.I: I host on godaddy)
    Thanks in advance!

      • Anderson Tagata says

        Hey, this worked for me. My wordpress website is on Godaddy and i was trying to put inside of subdirectory. now it works. Just after this, show up some database upgrade screen then everything is fine. also, i took out these defines above and still working. thanks.

  18. Zac says

    Thanks heaps for your info guide, helped me fix my problem.
    To let you know my resolve, I could not see a typo in the wp-config.php but decided to delete my Database and linked Username. I then created new ones and manually updated the new data into the wp-config and boom straight in. One thing to note is the database and username were originally the same name, so not sure if that was an issue as its a new site.

  19. Seth says

    My website is down and I keep getting „Error establishing database connection“ message.
    I checked my WP-Config.php page and it looks fine on the inside, but when I preview it, the page says this

    Warning: require_once(reddoorplayhouse.com/open/wp-settings.php) [function.require-once]: failed to open stream: No such file or directory in /hermes/waloraweb096/b619/moo.reddoor1/wp-config.php on line 95

    Fatal error: require_once() [function.require]: Failed opening required ‚reddoorplayhouse.com/open/wp-settings.php‘ (include_path=‘.:/usr/local/lib/php-5.2.17/lib/php‘) in /hermes/waloraweb096/b619/moo.reddoor1/wp-config.php on line 95

    What does that mean. And what can I do? Thanks for your help.

  20. Michael Tidwell says

    This is a frustrating problem that has been happening multiple times to a few of my sites over the past few weeks. I can fix it easily enough by replacing the Unique Keys and Salts in my wp-config.php file (grabbing new ones at: https://api.wordpress.org/secret-key/1.1/salt), but then days later I have to replace them again… so while I can fix the symptom, I’m still trying to determine why this keeps happening at http://brioagency.com

  21. Andrew Stark says

    Hi

    Just thought I’d thank you for helping me fix a site.

    Changing localhost to the database IP address fixed my issue.

    Thanks

    Andrew

  22. Madhurie Singh says

    I had made copies of the files and saved them on the server.

    So when today the database connection error occured, I relaized, I had changed user, , pwd, database access but nothing worked.

    So renamed the current wp-config.php as wp-configold.php
    and copied the wp-config.php from the archive and pasted as wp-config.php.

    Voila it works.

  23. Michael Stelly says

    Forgot that the database is „local“ to the application. I used the site URL by mistake. Switched DB_HOST to ‚localhost‘ and all is golden.

    Thanks for the blog! +1

  24. Ben says

    You know sometimes you just find the perfect resource and it answers all your questions. I tip people for pouring me a cup of coffee. I wish it was super easy to just put a buck or two in the wpbeginner tip jar right now, but I guess a thanks will have to do.

  25. jAMIE says

    WP Beginner is just awesome & so is Syed! I don’t know how many times my search results have let me to your site and each time, I’ve learned something really helpful, useful, & practical.

    This time, with my database connection error issue, I just had to clear my browser’s cache. FML Anyways, that was the advice that I got after contacting my host. It seems to have worked & hopefully that’s all it takes! How to prevent it from happening again is above me.

  26. Fre says

    For me the issue was solved by properly setting “siteurl” and “home” in wp_options table did the trick for me, I could log into my admin and change everything!

    One day I’ll buy you a cookie!!

  27. Julie Anderson says

    I have a big problem… i did not set the site up and do not have axxess to the php or any files. i was trying to add pages and the next time i visited the site there was the error. Do i need to get to the admin initiator etc, is there no other way into the site?

  28. Stephen Doxsee says

    I get this error intermittently. Perhaps I don’t have enough resources on my amazon ec2 free tier instance. I’ve had the problem 3 times in the last week but have been able to solve it each time by restarting the database server.
    Thanks for the post

    • Mana says

      Thank you so much, Udumbuke. This was exactly the step I forgot in moving my site to a new host. I’m so glad I can stop headaching over this! And great guide altogether on this site.

  29. Joyce Keller says

    This error happened to me because I wanted to back up my database and could not remember the password. I changed the password in GoDaddy – but this didn’t change it in the wp-config.php! Once I changed it in wp-config, everything worked okay again.

    THANK YOU FOR SUCH A COMPREHENSIVE SOLUTION!!! And a truly useful site. Kudos!

  30. JD says

    In step review of wp-config.php you have to consider the user name and password that is there in the file, the user may not exist in the database (mysql), the password has changed so check if there is the user. In case the user does not exist in the database create it, assign the password found in wp-config.php and provide permits for administration of the database (DBA).

    This happened to me to restore my wordpress.

    • Oliver Wieland says

      Thanks dude! Restored my database and all i needed to do then was reassign the correct user with the correct database in cpanel.

  31. Pat Walsh says

    Hi guys, thanks for this info.
    Helped me to fix a problem with a WordPress site I created.
    It had been happily running for over a month when it started having the „Error Establishing a Database Connection“ error.

    Finally fixed it by changing DB_HOST to use the full host name rather than the ‚localhost‘ that had been in there before.

    I don’t know why it worked initially and then stopped working. But its working now…
    Cheers,
    Pat Walsh

    • Forma says

      Having the same connection to DB problem, and after reading comments, I decided to change the wp.config file refrence to my actual host to localhost and for some reason that fixed it. So my solution was the opposite to the one above. Just a shot in the dark…

  32. Arifur Rahman says

    I’m getting this issue temporary at my site just for few seconds.
    how can I be free from this?
    Please help!

      • Arifur Rahman says

        Thank you,
        I already upgrade my hosting plan from basic to Pro.
        But still same as before.
        I using Adminimize, AG Custom Admin, Akismet, BuddyPress Template Pack, Display widgets, Fast Secure Contact Form, Google XML Sitemaps, Jetpack by WordPress.com, Page Views Count, Polldaddy Polls & Ratings, User Switching, Better WP Security, BuddyPress, Hotfix, W3 Total Cache, wordPress Importer and WordPress SEO.
        Which one is making problem??
        Have you any Idea?

  33. Eduardo Capanema says

    If you have all the info in the config file correct and is still having the problem, check to see if you have any spam prevention plugin active such as Fail2Ban. I found that it was causing the database problem. I believe it happens cause when you’re editing the wordpress via wp-admin, you make too many sequence requests to the apache it triggers the Fail2Ban service for www-data user. Try uninstalling Fail2Ban or any other spam controller. Then, restart both mysql server and apache to get hid of the Error message.

    I hope this helps.
    b

Eine Antwort hinterlassen

Danke, dass du einen Kommentar hinterlassen möchtest. Bitte beachte, dass alle Kommentare nach unseren kommentarpolitik moderiert werden und deine E-Mail-Adresse NICHT veröffentlicht wird. Bitte verwende KEINE Schlüsselwörter im Namensfeld. Lass uns ein persönliches und sinnvolles Gespräch führen.