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!

  2. cgjam says

    had this happen to me when trying to install word press, didnt realise i hadn’t actually enabled user privileges! thanks for this helpful article

  3. Moogie1947 says

    Just had this happen after I backed up my files and had set up a password to access and backup my database before I upgraded.
    Thanks for your site realised that I had accidentally replaced the autogenerated password (as I didn’t know it existed) . So I found it in the config.php file in my backup set and reset it in the admin panel on my host’s site. All now OK.
    Can’t thank you enough for a brilliant article.

  4. ValentinaMercenaro says

    I’ve tried them all! Eventually I solved by creating a
    different DB Username in my host cpanel (giving it all the privileges of
    course) and also changing the DB Host to my server IP in the wp-config.php file.

    I’ve got no clue why that would solve the issue but perhaps
    it could be that the DB Name and DB Username cannot have the same name. (You may think: „duh! Of course not!!!“, well, my host’s „DB Creation Wizard“ had auto generated the two fields and, believe it or not, it wouldn’t let me change it at the beginning). I had to create a new user
    separately later on to solve the issue.

    Thanks for this great post. x

  5. bfadmin1 says

    You’re the best ….
    I didnt know that changing the db password would drop the database connection to wordpress ….
    Solution 2 was brilliant ……. 2 min max.
    Thanks alot!!!

  6. needhelpquik! says

    hello…i am getting this error. it just happened out of the blue today! nothing was changed other than some text on a page. i logged out. now i got the error.

    in one of the paragraphs you state: „First thing you should do is to make sure that you are getting the same
    error on both the front-end of the site, and the back-end of the site
    (wp-admin). If the error message is the same on both pages “Error
    establishing a database connection”, then proceed onto the next step.“ what is the next step? i get the error on both sides.
    this was confusing to me. sorry. so what is the next step so i can try to figure out how to fix this!
    thanks for your help!

  7. PeterBestel says

    This error happened to one of my membership sites, except when you logged in, the site looked and acted normally.

    After following the usual routes, including changing the database user and accusing the theme of being the culprit, I discovered an extra „?>“ at the end of the wp-config.php file. Once I deleted that everything worked.

    I have no idea how that ended up there. Hours of frustration sorted by deleting two characters!!

  8. George Stroud says

    With this problem I found that it was a database corruption but that it resulted in my not being able to access the WordPress repair tool – however, I could effect a repair by using the mySQL section in my hosts control panel (cPanel) and then the site came straight back up.

  9. Jenerwin says

    just encountered this type of error..and i be able to fixed this through database optimize and repair..i like this post..thumbs up..

  10. Carrie Case says

    I had the Permalinks set to Post Name. I switched it back to Default and the error went away and my pages re-appeared. I then switched back to Post Name because I prefer this setting, and it still worked. Good to go. Only took several hours to figure that crap out. Lol.

  11. Joninashby says

    Saved my life – changed the database password within the hosting control panel, had no idea I had to update it in wp-config. Hours of stress avoided – thanks!

  12. BillR says

    I had this issue today.
    Server had crashed last night and was attended to fairly quickly when the issue was known.
    All worked for a while but today WordPress couldn’t make a connection to the database.
    The Simple Machines Forum database was working ok and the forum would load.
    What I did was:
    1. Create a new database user
    2. Assigned that user to the WP database with full privileges.
    3. Updated WP_config to use that user

    After that all was good.

    Seems that after a server issue the WordPress user privileges can become corrupt or changed even though the user is shown with full privileges.

    Thanks for this post. It pointed me in the right direction.

  13. Enhow says

    Hi! I having constantly this issue, I go to the webpage and it shows this error, but then I refresh some minutes later and the error it’s gone. It stopped happening so I even forgot about it. But today I asked my work partners (4 people) to enter the site at practically the same time to see the new mobile appearance and some got the error and others didn’t (it wasn’t exactly at the same time since I asked to do it in their phones and everyone had different speed) this concerns me a lot. I read you told someone else who also had this issue but it fixed by itself that it was because of his server. Should I call my server and ask what’s going on? Or is there a chance I did something wrong? Almost everyday it’s weird and it just go away. Thanks!

  14. Terry says

    Sorry guys,but for a real beginner your information appears to assume a greater knowledge on how to do stuff than perhaps some of us have.It’s ok to say,check this or that, but when we have no idea how to get there, it is not much help.I know you are saying that we should not be here if the tech. level is not there, but that does not help.One can follow a more step by step procedure but perhaps that is asking too much.Thanks.

  15. Chuck says

    Last night my Centos server crashed and when it came back up I had the error.

    What worked for me was to rename the file /var/lib/mysql/mysql.sock, start the mysql service with service mysqld start, shutdown the server with shutdown -h now, then bring the server back up.

    Basically, the crash had locked up MySql so it thought it was running when it really wasn’t.

  16. Bart says

    Thank you very much!

    In my case I fixed it by

    1) deleting the current user that was connected to my database
    2) creating a NEW user with all privileges
    3) adding this user to the database
    4) refreshing my details in config.php (user and password)
    5) refresh my site (F5)

    Furthermore, although I hadn’t changed anything about this, when I reloaded my WP admin page, a Fatal error occured which told me that the Facebook plugin was creating some sort of memory exhaustion. I disabled the plugin by renaming it in wp-content/plugins and got rid of my problem.

    This, by the way, also solved some display issues on my homepage.

    Hope this feedback helps and again, thank you very much for sharing this article!

    Bart

  17. Ruthie says

    When I went to login to my company’s dev site this morning, I got this message (on the back end and on the front end), but 10 minutes later I refreshed the page and it wasn’t a problem anymore. On the one hand, I’m glad it resolved itself, but on the other hand, I’d really like to know why it happened and how it got fixed so it doesn’t happen again. Any ideas?

  18. Derek Smith says

    I am having a database error that I need help with. I bought 40 WP sites and transferred them from one host to another (GoDaddy). I made the mistake of switching some content on the sites before switching the DNS. I switched all of the domains last night to match the DNS of Godaddy, not I am getting database error problems with all of the sites that I worked on.

    I’m kind of a newbie on the backend side, but I’m thinking that changing the files and then pointing the DNS after this somehow messed everything up, this is the only thing that I could come up with since the sites I didn’t touch still work. Thanks

    • WPBeginner Support says

      First you should have backedup your old databases using phpMyAdmin and then import them to your new webhost’s database server using phpMyAdmin. You should then change your DNS settings to point to your new web host. After that you need to edit wp-config file on all your sites, change the database name, password, host, settings to match your new databases.

      Admin

      • Derek Smith says

        What do I do to fix it now that it is at this point? All the DNS settings are changed and I keep getting the error messages. Is there a way to go back and install the original files ?

  19. Tony says

    Hi there…
    I’ve been working with a local install for a while now and wanted to change the url of my local install to something else, so I went ahead and changed quite a few times my wp-config database name, my mamp settings of the database in „wp-options“..plus some others I don’t know remember. This resulted in „error establishing database connection“. I troubleshooted for a whole day, (returning back to the same nightmare I got when I first installed mamp and wordpress locally). I changed everything back the way it was to no avail, making me feel soooo frustrated and stupid again…! So, I read this article to the end and where it says „siteurl“ solution in the „Solutions that worked for others“ section and went back in phpmyadmin to check this…surely enough…in the „wp-options“ of the particular database, in the „site url“ field, it had the name of my database, (which I had stupidly changed previously without realising its impact), I also checked it against other databases I could access with no problems and the field indeed said, „siteurl“ instead of the actual db name!
    I changed it immediately and phewww….got my database back and working and logging in with no problems..!!
    People, if you did something similar, check this first…it surely made me feel stupid…at least I have another troubleshooting trick up my sleeve now…thank you for your input..!

  20. Thouhedul Islam says

    Well, thanks for details. But I think, it is very simple. Don’t take it complicated like you. Just open wp-config.php and change the database username and password. Hope it will be fix.

  21. Tamas says

    Hello,
    Thanks for this description.
    I just moved my site from BlueHost to DreamHost.
    When going to my site I get an EMPTY (really empty, white) page. Nothing else.
    However, when I go to wp-admin… „Error establishing a database connection“ is displayed.

    I can log in into the MySQL (going to msql.remete.org) and it works.

    All four parameters in wp-config seem to be oké, as well:
    /** The name of the database for WordPress */
    define(‚DB_NAME‘, “);
    /** MySQL database username */
    define(‚DB_USER‘, “);
    /** MySQL database password */
    define(‚DB_PASSWORD‘, “);
    /** MySQL hostname */
    define(‚DB_HOST‘, “);
    Here I had replaced the „localhost“ by the „msql.remete.org“, as it should be with DreamHost.

    My site is remete.org.

    I moved already several WP sites … and some worked well, some had the white page at the root, however, this is the first and only one with „Error establishing a database connection“ error.

    How may I make the DB connection work?
    How can the root made work, as well (instead of the white page)?

    I would really appreciate your help.

    Thanks a lot,

    Tamas from Budapest

  22. Shlomi says

    for a multisite deployment, you also need to check the table wp_blogs and make sure the correct URL appears there, otherwise wordpress will say „error-establishing-a-database-connection“

    • Matt says

      DING DING! I had pulled down a copy of production data and was suddenly getting this error with a multisite instance. Updated the „domain“ column in wp_blogs and it works again. Thanks for pointing it out!

  23. Alex says

    Hey man. I just wanted to thank you for this GOOD post. It didn’t work and I didn’t know why.
    I read your blog and followed everything and now it works again.. after 11 HOURS of work.

    This is a sign of appreciation.. If you were here I’d get you a huge beer. Thanks so much for your clear help!

    Alex

  24. Travis says

    Oh my goodness. Typically posts like these usually don’t pan out for me after following directions… but you sir have saved the day here. Thank you!

  25. Tish says

    Thank you so much for this! I definitely thought I had lost my site completely until I followed this. My only hangup was that I had no idea where to find the wp-config.php file without being able to get into wordpress. I eventually found my file manager through my hosting, but it took me a while to figure that part out. Keep the great info coming!

  26. Michael says

    OR….

    *IF* you were messing around in the editor with any of your .php pages/code in the editor and your copy/paste back to the original did not work on this database connection error… the work-around is to then copy/paste back via FTP to the exact folder of the .php file rewriting over the edited one and this will for sure work to get your site to show back up online again.

  27. superfunkie says

    Hi! Im facing the same problem with the wordpress. I did copy and paste the testconnection.php and it showed „Access Denied“. But when I edited the line – „mysql_connect“ to „mysqli_connect“ database was connected successfully. How do I implement „mysqli_connect“ in the wordpress config file?

  28. Aaqil Mahmood says

    I am seeing „a secure data connection could not be established“ on android browsers for my site

    , only when reading posts not on homepage.

  29. marcel says

    Hi there,
    I am desperately trying to launch a new install of WordPress with MAMP, both Apache en MySQL give green lights, but when starting up in the browser I get the „Error establishing a database connection“ message.
    I am relatively new and most of the options above seem rather advanced, and for websites that have already been working, is there a simple way to tackle this for new installations of WordPress?

    WordPress was supposed to be not too difficult to install….

    Thanks in advance!

    • WPBeginner Support says

      marcel open the wp-config.php file in your WordPress install folder. And check your database username and password. Usually on fresh install of MAMP database username should be root and password should be left blank.

      Admin

  30. Gautam Sharma says

    i am a newbie & my site data access via filezilla, Please tell how to test connection as i have not seen any phpmy admin in hosting control panel.

  31. Jen Barnes says

    Pardon my seemingly dumb question, but what do I put in for „root“ in the MySql test?

    $link = mysql_connect(‚localhost‘, ‚root‘, ‚Q3dDZE3PiUpQ‘);

    Thanks!

    • WPBeginner Support says

      replace root with your MySQL username (unless your MySQL username is already root then don’t change it) and then your password. Let’s assume your mysql host is localhost, username is jenbarnes and password is Q3dDZE3PiUpQ then you would use it like this

      $link = mysql_connect('localhost', 'jenbarnes', 'Q3dDZE3PiUpQ' );

      Admin

  32. Kasper says

    Hey, I can’t launch my site as wp-admin or just visit the site?
    what to do? It’s all my 4 domains there’s been down by this error (below)
    „Error establishing a database connection“
    Please help me!

    – Kasper

  33. Asif says

    Oh! thank you guys! I almost had a heart attack.
    This was the first time I was backing up my data (so that my website doesnt crash or even if it did I could recover it) logged in to PHPadmin panel changed the password caz the original one was auto generated. logged in and backed up. relieved I went back to my website and boom! these big letters: Error Establishing a Database Connection
    man, you can understand I flatlined for a few seconds..

    Anyway thanks alot!!

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.