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. Barry says

    Under CentOS 7, I saw: Could not connect: Can’t connect to MySQL server on ‚xyz‘ (13)

    The problem was due to SE Linux, as documented at

    The problem was corrected using the command:

    sudo setsebool -P httpd_can_network_connect_db=1

  3. Alberto says

    After installing and setting up Mamp and a fresh WordPress on a friends machine, had the dreaded blank page and „error establishing a connection“ in the logs as well.

    After pulling my hair for a while, I noticed that the quotation marks in the wp-config.php file had been changed from straight ones ‚ to curvy ones ’ in the few settings one has to edit, and this was causing the errors, the culprit?

    -> TextEdit <- I had used it to make those changes. In it's preferences, the "clever quote marks" setting should be turned off if you want to have those quotation marks remain as they should be.

    • ka says

      Thanks Alberto. Textedit has automatically overwritten the straight quotation marks with curly ones. replacing them with straight ones and saving the php file again did the trick. :)

  4. Zoe says

    Hello, I’m new to wordpress and need some more help.
    My wp-admin page shows the „One or more database tables are unavailable. The database may need to be repaired“ message…. so I know I need to add that bit of code. But how and where do I add it? I can’t login… I do not know what address to type in to access this php file. Help please :)
    My website is

  5. Pavanswin says

    I am a wp beginner, you guys are awesome, helped me building my careers through this kind of articles. I migrated my website to and struggled with the error for many days and finally found a solution in the article and is very helpful. thank you all

  6. Julio Sanchez says

    The original name of the file wp-config is wp-config-sample, I just wrote the original name and vuala no „Error establishing a database connection“ message.

  7. Guy Pribyl says

    Is there a way to have wordpress when posting this error message do a redirect to a non-wordpress page? I JUST WANT A BACK UP FOR WHEN THIS HAPPENS IN THE MIDDLE OF THE NIGHT.

    Thanks for your help

  8. Avioconsys says

    Thanks Syed Balkhi and his team. It took me 5 minutes to solve the issue with this error. It was a bad update of the password for the general user.

    Fast and working. Very nice of you sharing this information.

    M.

  9. Suhel says

    i am getting the different error but its something some like this,
    wpsa_options: Table ‚aamtechn_wp949.wpsa_options‘ doesn’t exist
    wpsa_postmeta: Table ‚aamtechn_wp949.wpsa_postmeta‘ doesn’t exist

    i am getting this message and i am not able to access the dashboard.please help me soon.

  10. Camaal Mustafa Sikander says

    Thank you so much, this one fixed the Database error for me in the first step itself.

    Best wishes,
    Camaal

  11. Robert Varga says

    I had this problem, and I spent 2 much hours on fixing it … Finally I solve that mistery. My problem was in htacces file, it only had Rewrite Engine line , I just c/p this „default“ htaccess content in it and replace it with file on server, and tadaam it work now :D

    „default“ htaccess content :

    # BEGIN WordPress

    RewriteEngine On
    RewriteBase /
    RewriteRule ^index\.php$ – [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.php [L]

    # END WordPres

  12. prince vashisht says

    I changed the username (wp_users) from phpmyadmin and now I am getting the same issue.Reverting the changes is also not helping me out.Please help.

  13. Wayne says

    When I first experienced this error I was so devastated and I wonder how will I resolve this issue. I did some research and noticed that my database name was the problem. So I went into MYSQL and change the database name. This article explains it all

  14. Kevin Wells says

    For whatever reason, I ended up having to recreate my MySQL user in the database. After I did that, my website functioned normally again.

  15. Christine F says

    Thanks so much for this!

    I encountered the same issue earlier. I changed the database password and then this error appeared. We have GoDaddy so what I did was just go to the File Manager, open the WP-Config.php and changed the (‚DB_PASSWORD‘, ‚database-password‘); to the one I recently used. Real simple but wouldn’t have done it without this article.

    Thanks again!

    • Matthew says

      Thank you for this reply, Christine. I, too, changed the password and found that to fix the issue as well. Perhaps MySQL had reset it without notifying me.

    • Dutch says

      Thanks for this tip! Don’t know how you figured this out from the article. Was about to reload everything..and tried this just in case and it worked. Also on Godaddy, used Installatron to start the installation and uploaded the rest manually.

  16. Alexander says

    In my case I solved the problem just updating the password of the DB.
    It seems the password was to weak.

    ciao
    Alexander

  17. sonu arora says

    hey i m facing a weird issue with my website, i.e. when i try to check in pingdom then the screenshot generated there shows me data connection error, while when i am opening my website in normal tab or iphone, it gets open. could you please suggest me what to do? i am worried whether my website is showing to public or not. url is thanks in advance!

  18. Angel says

    You say to put this in your wp-config.php file….. define(‚WP_ALLOW_REPAIR‘, true);
    you don’t say a single word as to where to put it. I dropped it in right at the top and got a HUGE WP error message. You had it on line 1 without anything to indicate context of where to put it. So most would assume it would go on line 1 at the top. If it doesn’t go there, why not give helpful and specific instructions?

  19. Nica says

    when i try this:

    I get an error:
    Could not connect: Lost connection to MySQL server at ‚reading initial communication packet‘, system error: 95 „Operation not supported“

    When i test this to php:

    It shows:
    This site can’t be reached

    The connection was reset.
    ERR_CONNECTION_RESET

  20. RINKU MEHAR says

    how could i solve this errors:

    Warning: require_once(C:\xampp\xampp\htdocs\wordpress\wp-admin\admin.php): failed to open stream: No such file or directory in C:\xampp\xampp\htdocs\wordpress\wp-admin\index.php on line 10

    Fatal error: require_once(): Failed opening required ‚C:\xampp\xampp\htdocs\wordpress\wp-admin\admin.php‘ (include_path=‘.;C:\xampp\xampp\php\PEAR‘) in C:\xampp\xampp\htdocs\wordpress\wp-admin\index.php on line 10

  21. FranciscoMary Aghogho says

    Please I need an assistance here. I tried changing my site’s url from http to https and now cannot view my site. It say a coonection could not be established. Please what could I do in this instance. Thanks.

    • sourcebreak says

      Issue
      If you update from php 5.2 to 5.4 or 5.5 then you will get this error database connection error in wp.

      Cause
      If your password is Pre mysql 4.0 then you will get this error

      Fix
      Login to phpmyadmin >> user >> change password
      type your mysql password >> select >> MySQL 4.1+ compatible and go

  22. Kanif says

    I was also facing this issue. I googled it and come to this post. It is really awesome, deep thinking on what all problems may come with this error.
    Mine problem is resolved by doing database repair and optimization.

    Thanks buddy,
    Kanif

  23. ScienceMan says

    Thanks for the great post. My situation was interesting, I migrated my server to another account with the same provider. The result was the dreaded „Error Establishing a Database Connection“. Thanks to this article, I knew to have a look at the wp-config.php file.

    When I logged into my new server cPanel and checked the MySQL databases, I immediately spotted the problem. Due to the server migration, the name of the database and user had changed. The databases names at my provider all default to „accountname_databasename“. Also, the database username defaults to „accountname_username“. I suspect other servers are similar.

    Since my server account name changed with the server migration, so did the name of all my databases and database usernames.

    So to fix it, all I did was change these two lines in the wp-config,php file:

    /** The name of the database for WordPress */
    define(‚DB_NAME‘, ‚XXXXXX_databasename‘);

    /** MySQL database username */
    define(‚DB_USER‘, ‚XXXXXX_username‘);

    Basically, you want to check carefully to make sure the „XXXXXX“ in the wp-config.php file matches what’s at your server.

    Thanks again!

  24. igwe simon says

    I mistakenly changed my site and wordpress url to one of my domain so i had to go and change the dns and park it on the website, so i waited for some hours but the domain was still propagating then i read a tutorial (codex.wordpress.org/Changing_The_Site_URL) and followed an option there by editing my functions.php and the next thing i saw was „One or more database tables are unavailable. The database may need to be repaired.“, so i followed the instructions here and still the problem is still active. I need an assistance please.

  25. hafsa munir says

    I have following error in my xammp server,how can i resolve it
    he following error was encountered while trying to retrieve the URL: localhost/phpmyadmin/

    Unable to determine IP address from host name .localhost

    The DNS server returned:

    Name Error: The domain name does not exist.
    This means that the system was not able to resolve the hostname presented in the URL. Check if the address is correct.

  26. S says

    hai
    i done everything as you mentioned in the post but when i opened wp-admin/ then again this error was coming „One or more database tables are unavailable. The database may need to be repaired.“
    So plz help me what to do

  27. Manny says

    Thanks!

    I just logged in through FileZilla and checked out the wp-config.php file and double checked everything and realized that I updated my database password but it still showed the previous default password on wp-config.php. So after changing it in the file and saving the changes I was able to access my site again. Your help allowed me to solve my problem, thank you!

  28. Jeremy Smith says

    One very important that’s been left out in this post is the „turn it off and turn it back on again“ approach.

    If you haven’t actually changed the wp-config file I don’t think you should be going in and fiddling around with it, at least not in the first instance.

    What you should do first is attempt to restart the mysql server.

    To do this (In Terminal)
    1. SSH into your website (you will need your key ‚.pem‘ file)*
    2. To restart your mysql type „sudo service mysqld restart“

    This has worked every-time for me.

    *On a Mac
    1. Get your ‚.pem‘ file. I got mine from Amazon Web services (hosting the site)
    2. Enable SSH on your Mac – Google it
    3. Open Terminal
    4. Change directory to where you have stored your ‚.pem‘ file. -It’s probably easiest to save this on your desktop, then you can just type ‚cd Desktop‘ and it should take you there.
    5. Type ‚chmod 400 yourpemfilename.pem (allows you to use this key to get in)
    6. Type ’ssh -i „yourpemfile.pem“ remote_username@remote_host – type the speech marks here
    7. Once logged in (You may have to type y a few times to get you in) type
    sudo service mysqld restart

  29. Malkesh says

    Hi, my wordpress site gets this error very often,
    we are using AWS, so i need to run this command to restart mysql :

    sudo restart mysqld restart

    the same issue i have also on digital ocean too..

    so i am sure not this is not an server issue, it’s should be some thing in wordpress, that’s put down mysql server..

    Thanks

    • dino says

      Same problem here. At least two times per day my site , which is in digital ocean , loose sql connection.
      I have try to optimize my database, bvut nothing works. Any idea?

  30. Glenn says

    Thanks,

    When WordPress dies it is scary for a WordPress newbie. I found your solution easy to understand, implement and worked a treat.

  31. Faiza says

    Hi,

    This blog was very helpful but I still haven’t been able to figure out this problem. My WP-Config.php file shows me this localhost:

    I am using GoDaddy, I have tried replacing this with local host, my IP address, and (godaddy). Nothing has worked :( Can I get some help here?

  32. Brandon says

    WOW!!!! Came across this site because my wife’s business site went down and I was able to fix it in minutes! Thank you!

  33. Cidina says

    Thank you soooo much. This post saved my 6-month large project in WordPress. Trying to switch directories I lost connection to the database. I’m not a .php programmer but the topic is so well explained here that it took me five minutes to fix it after finding this blog. Your are awesome!!!

  34. Nino F says

    If you changed your password in phpmyadmin, you have to change it in your wp-config.php aswell, if you don’t do that the website doesn’t work. You have to link the two with eachother.

  35. Eddie O'Hagan says

    I was getting this error I think because of the theme I had, I changed the theme and I haven’t gotten the error since, I noticed this because when I ran the repair, the comments tables were the ones that had the errors.

    • dino says

      how often did you have this problem?
      I have the same , and i loose connection at least twice per day.
      I tried many things but nothin works. If it is the theme i will try it..

  36. Ram says

    if you use xampp for wordpress offline then the error is removed by following process:
    open in Xampp folder „\xampp\phpMyAdmin\config.inc.php“ and then check username and password
    set the same password to wp-config then the error is not appear

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.