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

Hinweis der Redaktion: Wir erhalten eine Provision für Partnerlinks auf WPBeginner. Die Provisionen haben keinen Einfluss auf die Meinung oder Bewertung unserer Redakteure. Erfahre mehr über Redaktioneller Prozess.

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!

  2. Abul Fayes says

    Either ‚127.0.0.1:8889‘ or ‚localhost:8889‘ works for me. Just using ‚localhost‘ with no port specified does not work. I am using MAMP

  3. Joe says

    The frontend of my site is connecting but the wp-admin section is showing the error establishing a database connection.

    What do I do?

  4. Gill says

    Thanks! Life saver. Completely borked my site changing passwords. Could have sworn I’d done everything right but managed to fix it in config.

  5. Praveen says

    My problem was due to a google analytics plugin, the day i installed it, my site was down saying „Error database connection!“ Even I was unable to login into my admin panel. So, I manually removed that plugin from cpanel, and everything worked.

    • Andreja says

      Hi Praveen,

      thank you for your info. Can you please explain how to find particular plugin in cpanel to remove it? I received this error message right after I’ve installed „All in one SEO pack“ plug-in in my Worpress site so I guess it could be the same problem as your problem was…?

      Thank you in advance!

  6. Matt says

    I was on a Digital Ocean 512MB droplet and was getting this error every couple of weeks. Inspecting the logs showed that a process called update-apt-xapi was consuming all of my memory and causing the mysql service to crash resulting in the error. You can try setting up a swap file but, really, 512MB just isn’t enough memory to run a WordPress install. Upgrade your droplet to 1GB and that should take care of the issue.

    • Joween Flores says

      We have the same issue here friend. How’s your website going since? I was trying to cheap on server expenses now.

  7. Ob says

    I just checked MySQL server with „service mysql status“. Apparently, MySQL server was not running.
    So, I started it with: „service mysql start“. And Voila! my website was up.

  8. Kishan SHarma says

    What i found is it was faulty plugin which was causing trouble , try deactivate plugins and check if problem persist. changing localhost to 127.0.0.1 also solved some issues

  9. Jim Zimmer says

    I did a search through your post and didn’t find anything about SELinux being the culprit, which ultimately was my problem. I have segregated my web server from my database and disabled SELinux on both VMs. I tried your testconnection.php, which was successful from within the /var/www/html directory before disabling SELinux, so I really have no idea if it is the database or the web server that has the issue. I will try and update this comment with SELinux settings that work when I have tested it.

  10. Andrea says

    I have this problem right after having changed the password for my admin access. Can you super kindly provide a solution written in a language understandable for someone who has close to 0 programming or web-developer knowledge?? I have the error for both front-end and back-end. I have NO IDEA how to „check the wp-config.php“ file (never heard of it until now). How do I proceed?

    Thank you so much,
    Best,
    Andrea

  11. Binyam says

    What did work for me was this: In cPanel, go to Advanced Zone Editor select the domain copy the recorded IP and as wpbeginner suggested I replacing localhost with the IP and it works! Thanks!

  12. Avinash says

    I was having the connection problem. The problem was my previously installed MySQL, was running. So I stopped it and then ran MySQL of Xampp. It worked. Hope it helps.

  13. Avinash says

    My previously installed mySQL was running. I stopped it and then ran mySQL that came with Xampp. it worked. Hope it helps.

  14. Swati says

    We had our wordpress installed on AWS EC2 and we got the „Error establishing database connection“ for all our sites when the database was installed on the same server as the web server. When the database was moved to Amazon RDS for each of our sites, that error did not recur.

  15. Scott says

    Greetings.

    I have recently experienced the same issue when moving my multi-site from a subdirectory to root. Even after going through all the steps outlined in various tutorials, I encountered this dreaded message and nothing I did seemed to work.

    What did work for me was this: In cPanel, go to your softaculous script installer, select the edit icon for your WordPress installation, change the paths that point to your install.

    Once I did this and saved, then navigated to my site URL, it was back up and running smoothly.

    Just wanted to leave this here in case it helps someone else along the way.

  16. Sysy says

    I have an issue with database connection. I wanted to create a new database for a new website #2 connected in multisite in OVH, and when wordpress asked me to enter login, password etc I entered those of website #1 as I had to do BUT without changing „wp_“ for „wp_2″… And now both of these two sites have the message „Error establishing a database connection“. I deleted all FTP WP for website #2 and deconnected from multisite, but impossible to get back and to enter in website #1!! Do you know how to resolve this problem?

  17. Taurai says

    I’m having an issue with my website, my WordPress database just seams to disappear. logged into MySQL and nothing exist there anymore. has anyone ever experienced this? anyone with a solution?

  18. Gail Gardner says

    The cause of this issue when I had it was so many people running hacking programs against my login page that they were impacting the server. It happened every Friday evening through Sunday evening.

    We eliminated the issue by protecting that page with a pop-up so they couldn’t run their automated hacking programs against the login page.

  19. Rita says

    Thank you for posting this–it saved a bit of a panic when the company’s WP blog disappeared behind this error. After verifying that the database was still there and undamaged, I called our host.

    Turns out they’ve been migrating customers‘ web sites to new and improved servers, and they somehow lost the connection info. Hopefully it will be repaired today.

    But a very informative article, and a quick reminder (for me) of how to check in on mySQL to make sure everything is still good. Thanks!

  20. adams says

    i cant create pages, new post, or edit my themes or even upload pictures i constantly get the following error…

    This page isn’t working.
    didn’t send any data.
    ERR_EMPTY_RESPONSE
    the website setup is new but am faced with this problem

  21. jitesh says

    How can i find my wordpress database username and password?

    By Mistake, i have deleted wp-config.php file and now i have uploaded new files.

    I am Using Godaddy’s windows server…

    I am getting below error:

    This either means that the username and password information in your wp-config.php file is incorrect or we can’t contact the database server at . This could mean your host’s database server is down.

    Are you sure you have the correct username and password? Are you sure that you have typed the correct hostname? Are you sure that the database server is running? If you’re unsure what these terms mean you should probably contact your host. If you still need help you can always visit the WordPress Support Forums.

    Please help me as I have wasted by complete week…

    Thank you..

    • WPBeginner Support says

      Hey Jitesh,

      You can login to your hosting control panel and locate the MySQL database section. Most likely, you will be able to find the database name, username, and password information there. Alternately, you can contact support to help you locate that information.

      Admin

  22. Bob says

    Thanks so much, all, for maintaining such a great website! You guys continue to bail me out with problems, issues & fixes for those of us who just enjoy writing & posting and not dealing with all of the WordPress programming stuff. Great work!
    Cheers!!!!

  23. Joette says

    Thanks for all the great articles. I am having such a problem tho just getting WP installed. I’ve followed your instructions regarding doing it with MAMP and keep getting the „can’t connect to localhost:8888“ msg. After much searching I found a terminal code to test apache. It returned with httpd not running, trying to start. I did it again and it didn’t return anything so perhaps worked.

    I tried connecting to local host again and this time I got Error connecting to database. At least this seems like progress! I tried some of your suggestions above and this time, it seemed to be trying to connect for quite a while, but finally gave me the Error connecting to database again.

    I have yet to get the happy WP page. Does anyone at all have any ideas as to what is going on? I have spent hours searching, contacting, trying this and that and I don’t know what else to do at this point. I am an absolute WP beginner.

    Thanks to anyone/everyone in advance.

      • Joette says

        Hi Ashley, No, unfortunately nothing is working for me either! I’ve yet to find someone who knows the answer & have been asking many places. For me, I think I’m going to use different software and leave WP for another time. Too strange, too much hassle.

        • Kalico says

          This isn’t a WordPress problem, it’s a MAMP problem. If you have to run this on a local server, try a different XAMP package. Better yet, get a shared hosting account and set it up there. Local XAMP can be frustrating.

  24. J M Landers says

    I missed that when you add the repair line to your WP config file you have to add it right at the end of the declarations before the first „if“ statement when I first read it. Took me a while to realize what I was doing wrong. Still didn’t fix my problem but at least I was able to strike one possible issue off my list.

  25. Muhammad Qamar40391 says

    Thank you for a great helpful post.
    Solved by resetting DB password but this process repeated several times. issue solved but page speed is too much slow now.

  26. John Malto says

    Also had the same problem and tried everything. TestConnection was failing. What I just had to do was manually edit the user password through MySQL Cpanel and it suddenly worked!

  27. Leslie limardo says

    I am so confused. First time on wordpress. No tech experience whatsoever. I didn’t receive any error. message. My website is up. The problem I had is when I set the page to update some updates would take effect and others didn’t. I called WordPress and they told me I didn’t set up the database correctly. Is this the same issue as this article or something totally different? Thanks in advance.

  28. Fran says

    Hi, i had this problem when I formatted my laptop and reinstalled XAMPP.

    Problem was, I forgot to create a new Mysql user with the same data (host, name and password) from my BD user stored on wp-config.php, just like we do when we configure one new WP site for the first time. That solved it :)

    So, maybe the problem is not that the user has not enough permissions… perhaps the problem is, user simply doesn´t exist yn mysql.user table! (as I said, it can be possible after formatting your computer).

  29. Kate says

    I just had the same problem, which I managed to solve by simply changing the DB password and correcting that in the config.php file.

    I have no idea why the password suddenly became an issue, though.

  30. Sheriph says

    Changing the localhost in my wp-config.php to the ip on my host account in godaddy cpanel did the magic for me. Even godaddy support were talking rubbish. Imagine telling to upgrade with about $200, that my hosting plan is low on resources. I almost believed until I found this article. Thanks a lot.

    • Steve says

      I still have the problem. GoDaddy tried but unable to help. They have a service that, for $80.00, will have a WordPress expert investigate. However, there are no guarantees she / he can fix the problem but you still have to pay the $80.00.

  31. Destiny Alabi says

    This review was very helpful,

    I had a similar issue with installation on windows server, I kept getting database error, and what I did was to replace localhost which was internal server to IP Address and Port which was external server and it worked perfectly.

  32. Sam says

    Mine just happened like 20 minutes ago, I am hosting at Ipage and WHAT A SCARE!!! It happened all over sudden and I could not access both the admin site and the website itself with my laptop but I could access the site with my phone.
    Then before I could complete reading this guide the site got back by itself lol. I want to know if there is a way to avoid this from happening in future.

  33. sreekan th reddy says

    my website is showing database connection error .

    can some one help me to solve the problem

    my website is created in amazonweb service

    for every 24 hours it showing database connection error
    the php-myadmin ,wp-content every thing is fine
    can plz some one help to solve this issue

  34. Martin L. says

    I have no WordPress account, but have been having this happen to me a lot recently on several sites. How can I fix this? (Note: I don’t own these other sites and I don’t think I can access their databases directly)

  35. imparthi says

    Thanks much for the article. I ran into the same issue.
    1. Wp-Config file was correct
    2. phpMyadmin connection was success
    3. testconnection.php approach too was success
    4. I tried to update the site URL I couldn’t get it as naming conventions of the table names of the WP changed

    THIS IS WHAT HELPED ME FINALLY.
    I selected wp_Options“ table in the phpMyAdmin window to browse the content, there was an informative Error message that, the table has to be repaired. (wp-config auto-repair didn’t work out)

    I was able to repair using the options available in phpMyAdmin and got my site back. :) Thanks all.

  36. jhaejhae jhaens says

    hi there.. can i please seek help.. i am working now on transferring my live WordPress site to local using XAMPP.. my database is doing good but i cant connect it during the WordPress installation. please help.. thanks in advance!

  37. Tanya says

    Hi there,

    Thank you for this article. My website was hacked recently and after I got no support from the hosting provider, I was told I was going to need to reinstall WordPress and upload the backup. I didn’t use a backup plugins (I am all the way in South Africa) as it is to expensive for the paid plugins. So I did a cpanel backup through Softaculous and downloaded the Zip of 1.03Gig. Two weeks later my site was hacked (Twice in one week). With the second hack my wordpress installation was comprimised – and backup deleted from server. So I had to delete the original installation and reinstall. Now I followed all the steps to upload the zip to file manager and now I am stuck with this: Error Establishing a Database Connection. I have tried all the suggested solutions from this post, but still no progress. Please help me! I am quite new to wordpress and this is my biggest client’s website.
    Kind regards,
    Tanya

    • WPBeginner Support says

      Hi Tanya,

      The most common reason for this error is incorrect Database information in your wp-config.php file. Confirm that you have restored your WordPress database correctly, then enter the mysql host, database name, database username and password carefully. If you are unsure, ask your hosting provider and they will let you know your mysql host and other information.

      Hope this helps

      Admin

  38. Mannu says

    Some folks suggested that they fixed their problem by replacing localhost with the IP.

    It worked for me….
    Any logical explanation for this…?

    • Nick says

      Think about it. ‚Localhost‘ is the name of a location. If changing that to the IP works, then ‚localhost‘ was not pointing where you need it to be.

  39. Ravi says

    I have MAMP installation on my Macbook. i.e I am running MySQL also on my local machine. My problem was that in wp-config.php, the database server ‚localhost‘ is not working. Once I changed it to 127.0.0.1, it started working.

  40. Mike Crisp says

    Repair database command worked for me.
    Front end or site was fine but couldn’t access admin panel – Repair found a damaged database file (wp-options) – repair worked

  41. JP Hoey says

    What i did was, in the cPalen i went into MySQL databases and scrolled down to current user and changed the password. I used the very same password that was in my wp-config.php file but for some reason the password was corrupt. Everything works fine now.

    • Chuck Moran says

      I got this error on a client’s site. After a bum steer chatting with a Bluehost tech, I called back and the phone tech support person I got did this same @JP Hoey trick (changing the DB pass and updating it in wp-config.php). Took 5 minutes and worked like a charm.

  42. Adam Coalbow says

    An obscure one for me…

    Don’t use #’s in your password.

    I had two hash tags in my password that was throwing something off in the PHP–since hash tags create comments I guess. I removed the hash tags and BOOM, I’m in.

  43. Ted Richards says

    First thank you for a well-documented article on „We were able to connect to the database server (which means your username and password is okay) but not able to select the XXXXXX database.“

    I tried almost everything outlined in the article but can’t fix my problem. Here is an outline and history.

    Local machine installation:
    I have installed MySQL 5.7.17 and MySQL WorkBench 6.3.8. And WordPress 4.7.2. The MySQL was installed after removing both an earlier version of MySQL and WorkBench. The previous version was displaying the same database error. The previous WordPress/MySQL worked about 2 years ago, but recently I contracted a project to develop a WordPress Web site, and I encountered this problem when I began setting up the new WordPress framework for this new site. The old WordPress site was deleted so I couldn’t test if that worked.

    So, I reasoned, why not try a fresh start and also upgrade to the latest versions, etc.

    But, this new version also had the same problem with not being able to connect to the database. I have narrowed down the problem to „permissions“ and I haven’t been able to crack the code.

    The MySQL Server logs verify this is this case:
    Timestamp, Thread, Type, Details
    2017-01-28T02:46:24, 134, Note, Access denied for user ‚root’@’localhost‘ (using password: YES)

    I have created a new WP directory and installed a fresh WP version etc.
    I deleted and created new databases in WorkBench and properly assigned them users and passwords.

    I have checked the Users and Privileges, Client Connections and can find nothing that would block access to the database.

    I have checked my Windows 7 permissions for the MySQL Directory and the sub directories. I have unchecked the “Read Only” to the master MySQL Directory and all directories and files are read/write.

    I have progressed through each attempt to connect to the database each time I change something.

    I am exhausted and very disappointed there isn’t a good response by the WP Support Team to this issue of “not able to select the database.” It is a “popular” issue that many developers are experiencing with no resolution–many more experienced than me, are having.

    You are my last hope!

    Thank you!

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.