errors establishing a database connection - Vorgehen

  • hallo und guten Abend,

    eigentlich müsste sich beim Installationsvorgang die Datei wp-config-sample.php zu
    wp-config.php umsetzen. Das passiert aber nicht.


    Zitat

    [size=24]Error establishing a database connection[/SIZE]
    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 localhost. 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.

    Ich editiere jetzt mal manuell die Datei u. speichere die dann als Wp_config.php auf dem Server ab. Btw: wundert mich etwas, dass dies nach mehreren Versuchen nicht von alleine

    Darüber hinaus: werde auch darüber hinaus noch folgendes machen:

    Zitat

    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. If you are getting a different error on the wp-admin for instance something like “One or more database tables are unavailable. The database may need to be repaired”, then you need to repair your database.

    gem. https://www.wpbeginner.com/wp-tutorials/h…n-in-wordpress/

    Code
    define('WP_ALLOW_REPAIR', true);


    Zitat


    once you have done that, you can see the settings by visiting this page:

    vgl, hier http://www.yoursite.com/wp-admin/maint/repair.php

    ich komme zurück u. berichte.

    • Anzeige

    Hallo!

    Wenn du gerade an deiner Website arbeitest oder dein aktuelles Hosting überdenkst: Wir betreiben mit NetzLiving eine Hosting-Plattform, die speziell auf Performance, Sicherheit und einfache Verwaltung ausgelegt ist.

    • ✔️ Schnelle Ladezeiten (optimiert für WordPress & Co.)
    • ✔️ Deutsche Server & DSGVO-konform
    • ✔️ Persönlicher Support (kein 0815-Ticket-System)

    Mehr erfahren

  • hallo und guten Abend,


    nachdem die obigen Aktionen nicht zum Erfolg geführt haben - und sich nichts ändert versuche ich weiters....:

    https://www.wpbeginner.com/wp-tutorials/h…n-in-wordpress/


    Zitat

    Often you will notice this Error establishing database connection when your site gets swarmed with a lot of traffic. Basically, your host server just cannot handle the load (specially when you are on shared hosting). Your site will get really slow and for some users even output the error. So the best thing you should do is get on the phone or livechat with your hosting provider and ask them if your MySQL server is responsive. For those users who want to test if MySQL server is running yourself, you can do a few things. Test other sites on the same server to see if they are having the issue. If they are also getting the same error, then most definitely there is something wrong with your MySQL server. If you do not have any other site on this same hosting account
    simply go to your cPanel and try to access phpMyAdmin and connect the database. If you can connect, then we need to verify if your database user has sufficient permission. Create a new file called testconnection.php and paste the following code in it:


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


    Make sure to replace the username and password. If the script connected successfully, then it means that your user has sufficient permission, and there is something else that is wrong. Go back to your wp-config file to make sure that everything there is correct (re-scan for typos).

    was dann dabei rauskommt ist folgendes:


    Code
    Warning: mysqli_connect(): (HY000/2002): No such file or directory in /sites/www.mysite.de/testconnection.php on line 2
    Warning: mysqli_error() expects exactly 1 parameter, 0 given in /sites/www.mysite.de/testconnection.php on line 4
    Could not connect:

    Werde alles nun nochmals überprüfen und sehen wo der Fehler liegen kann.

  • habe das nochmals mit einem Testscript durchlaufen lassen - welches ich in das Stammverzeichnis der WP eingefügt habe:

    Code
    Warning: mysqli_connect(): (HY000/2002): No such file or directory in /sites/www.mysite.de/tests.php on line 3
    Warning: mysqli_error() expects parameter 1 to be mysqli, boolean given in /sites/www.mysite.de/tests.php on line 4
    could not connect:

    hier das Script:

    PHP
    <?php
    if(function_exists('mysqli_connect')){
    if(!($link = mysqli_connect('localhost','user','passwd','my_db'))){
    die('could not connect: ' . mysqli_error($link));
    }
    } else {
    die("don't have mysqli");
    }
    echo 'connect successfully';
    mysqli_close($link);

    einige Ideen:

    - Die Pfade scheinen das Problem zu sein - sie sehen doch so aus, als würden sie nicht passen - wie man auch im Ergebnis des Scripts sieht;
    by the way: das character-code ist 1252 ANSI L - ist das okay so!?


    Freue mich auf einen Tipp - vg:)

  • hallo b3317133, guten Abend,


    ....vielen Dank für deine schnelle Antwort - werde mit die von dir im Link gebotenen Ideen und moeglichen Gründe gleich noch näher ansehen. Danke dafür schon jetzt.

    hier nochmals ein paar Einfälle zu den bisherigen Befunden - insbesondere zu diesem zurückgegebenen Fehler:

    Code
    1 Warning: mysqli_error() expects exactly 1 parameter,
    2 given in /sites/www.mysite.de/testconnection.php on line 4


    PHP
    <?php
    if(function_exists('mysqli_connect')){
    if(!($link = mysqli_connect('localhost','user','passwd','my_db'))){
    die('could not connect: ' . mysqli_error($link));
    }
    die("don't have mysqli");
    }
    echo 'connect successfully';
    mysqli_close($link);

    ....ein paar Gedanken zu diesen Ergebnissen: Das sagt dann doch wohl folgendes:

    - 1 Parameter ist benötigt;
    - aber 0 oder auch anders gesagt, keiner wird angeboten;

    Es wurde mithin kein "error checking" ausgeführt ehe die Funktion aufgerufen wurde.
    Es wird praktisch "blind" eine Variable übergeben die anliegt.
    Im Grunde macht das ja auch Sinn - wenn man in Rechnung stellt dass die Verbindung zur MySQL-DB fehlschlägt.
    Nun mal abgesehen von der Validierung der Benutzerpassworte etc. etx.

    Aufs Ganze gesehen glaube ich sagen zu koennen, dass es eher unwahrscheinlich scheint, dass ich hier Pfadprobleme hab.
    Es sieht eher nicht nach wordpress-Pfad-Fehler aus.


    Hab in den PHP-Info-Daten noch folgendes gesehen:

    Code
    active_connections  18446744073709551563

    Ferner noch hab ich festegestellt dass auf dem Server noch ein PHP 5.6.39 läuft - Das ist definitiv veraltet u. wird gleich hochgezogen.
    Werde nun alles noch weiter untersuchen und mich wieder zurück melden.

    b3317133 - ich werde deine verlinkten Tipps gleich noch ansehen. Danke nochmals.

    vg

  • hallo @all

    um einen ganzen u. konsistenten Überblick auf das Thema u. die Erfahrungen hier zu geben setze ich den Thread hier fort:

    ...hier also ein kleiner Update mit ein paar DB-Abfragen und einigen diesbezüglichen Überlegungen zu Rechten / Benutzern auf einer DB.
    Auf dem Webadmin - Frontend will ich die folgenden sql-Statements absetzen - aber keiner der Befehle funktioniert.

    Code
    USE jo ;
    SHOW GLOBAL VARIABLES LIKE 'PORT';

    gibt zurück

    Code
    Failed to execute SQL : SQL USE jo ; SHOW GLOBAL VARIABLES LIKE 'PORT'; failed : You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'SHOW GLOBAL VARIABLES LIKE 'PORT'' at line 1

    während :

    Code
    USE jo ;
    SHOW GRANTS FOR CURRENT_USER;

    folgendes zurückgibt:

    Code
    Failed to execute SQL : SQL USE jo ; SHOW GLOBAL VARIABLES LIKE 'PORT'; failed : You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'SHOW GLOBAL VARIABLES LIKE 'PORT'' at line 1

    Anmerkung: jo - das ist der Name der DB
    hier das manual zu diesem sql-commando:

    https://beginner-sql-tutorial.com/sql-use-database.htm

    SQL USE Statement
    The USE Statement is used to select a database and perform SQL operations into that database.
    The database remains default until end of session or execution of another USE statement with some other database.

    SQL USE DATABASE Statement:
    The Syntax for the USE Statement is:

    USE database_name;
    database_name - is the name of the database to be selected

    USE DATABASE Example:
    If you want to use database MyDatabase, the statement would be like
    USE MyDatabase ;

    btw i es laufen die versionen auf dem Server
    - MySQL version 5.5.33
    - PHP 5.6.39


    Einige Überlegungen hierzu: ....da die Syntax richtig ist, stellen sich mir diese Fragen:

    Ich muss herausbekommen wie die Umstände auf dem Server sind: GGF hab ich ein User oder ein Berechtigungsproblem;
    - als welcher 'User bin ich bei MySQL angemeldet?

    Dazu sollte ich versuchen, mich mal mit der Kommandozeile auf der DB anzumelden:

    Code
    mysql -u USERNAME -p


    und wenn das funktioniert, wenn ich die SQL-Shell bekomme, nur das USE-Kommando absetzen:

    Code
    USE jo;

    Aus irgendeinem Grund, den ich im Moment noch nicht ganz verstehe, ist das USE-Kommando das Problem. Es meldet ja immer

    Code
    Error ... at line 1


    zu dem WEBMIN - (bzw. Webadmin)

    https://doxfer.webmin.com/Webmin/MySQL_Database_Server

    Zitat

    The options below configure synchronization between Unix users created through Webmin and MySQL users.

    when to synchronisize

    [ ] add a new MySQL user when a Unix-User is added;
    [ ] update a Mysql.-user when the matching of a Unix-user is modified;
    [ ] delete a MysqL.-user when the matching Unix-user is deleted

    Your MySQL database server requires all clients to authenticate themselves with a username and password before they can execute SQL commands. It has its own tables of users, passwords and permissions that are consulted when a client tries to login, rather than the Unix user files /etc/passwd and /etc/shadow. Detailed permissions can be defined for each user, in order to limit the kinds of SQL statements that he can use, the client hosts he can connect from, and the databases, tables and fields that he can modify. Typically after MySQL has been first installed, only the root user is able to login. This user will have permissions to access all databases and tables and perform all actions, and so is generally used for administration purposes only. If you want to write an application that uses a database, it is a good idea to create another user for that purpose and set up the application to login as that user. The standard MySQL install also creates an Anonymous user with no password and access to databases starting with test. This special user is used for any login attempt for which no other matching user is found. Anonymous users are explained in more detail below.Die Reihenfolge, in der ich das alles vorgenommen habe:

    wie ich vorgehe beim Einrichten einer DB auf dem Webmin-Frontend:

    1. setup eines DB-users und dann
    2. erstellen der db
    3. dem user Berechtigungen auf der db geben
    4. dem user user Berechtigungen auf dem db-host geben


    Ich denke dass ich hier vielleicht mit einem Rechteproblem zu tun habe, oder mit einem generellen" User-Problem" ... Insofern finde ich - wie oben bereits festgestellt, deine Idee mit der Konsole sehr gut - das wäre jetzt das allernächste was ich machen wollte:


    Aber da ich keinen Zugang zur Konsole habe muss ich nun überlegen, wie ich fortfahre mit Tests und Versuchen.


  • Auf dem Webadmin - Frontend will ich die folgenden sql-Statements absetzen - aber keiner der Befehle funktioniert.

    Code
    USE jo ;
    SHOW GLOBAL VARIABLES LIKE 'PORT';

    gibt zurück


    Und was ist jetzt schon wieder WebAdmin?

    Im MySQL client

    mysql -u root -proot -e "SHOW GLOBAL VARIABLES LIKE 'PORT';"

    tausche root durch dein "username" und "password"

    Kein Provider erlaubt dir mal eben die Änderung vom Port.

    Der Port von MySQL ist in der Regel 3306

    Deine Umgebung PHP und MYSQL ist veraltet und kann weg.

    Mit offenen Augen träumen

  • hallo und guten Tag r23,


    vorweg: vielen Dank für die Rückmeldung:

    - klar; die Umgebung für PHP und MySQL ist veraltet - ich werde die hochziehen. Das mit dem Port für die MySQL - 3306 ist auch klar.

    Webadmin - das ist ein Frontend für einen Server: https://sourceforge.net/projects/webadmin/
    A web-based system administration tool for Unix servers and services.


    Übrigens: wenn ich das STATEMENT einfach weglasse - dann gehts...Also - ich habe soeben festgestellt dass ich einfach dass USE <dbname> weglasse:

    Code
    SHOW GRANTS FOR CURRENT_USER;

    das gibt das hier retour

    Code
    Output from SQL command SHOW GRANTS FOR CURRENT_USER; ..
    Grants for root@localhost
    GRANT ALL PRIVILEGES ON *.* TO 'root'@'localhost' IDENTIFIED BY PASSWORD '*4444444rrrrrrwwwww222222444443660283C379783ED8EF54B6EC01DAF8374444444rrrrrrrrrrrreeeeewwwww2CeC3C474F4' WITH GRANT OPTION
    GRANT PROXY ON ''@'' TO 'root'@'localhost' WITH GRANT OPTION

    und ich krieg dann also das entsprechende Ergebnis für die betreffende DB .. Und jetzt geht es also um die _Interpretation_ dieses Ergebnisses im Rahmen des Problems - Error in Establishing a DB-Connection... beim Installieren einer Wordpress auf dem Frontend..

  • Hallo at all,


    ....und weil ich ja nicht root bin, wenn ich eine WP installiere sondern ein dezidierter DB-User
    hier das noch:

    Code
    Output from SQL command SHOW GRANTS FOR 'jo'@'localhost'; ..
    Grants for jo@localhost
    GRANT USAGE ON *.* TO 'jo'@'localhost' IDENTIFIED BY PASSWORD '*93C1B40FA5F0FED10E5A0CE946A5E71D59B00860'
    GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP ON `jo`.* TO 'jo'@'localhost'

    ich werde noch weitere Sachen untersuchen u. gucken was ich noch rauskriege...

    viele Grüße

  • Hallo r23

    jetzt geht alles tadellos.

    hier nur noch der Vollständigkeit halber: neues Build eingespielt.

    Dabei hat das neue PHP-Build den mysql pfad nicht aus der php.ini gelesen - deshalb musste es recompiliert werden und ein configure argument ubergeben werden.

    Die Socket Pfade sind - laut php.ini diese:

    Code
    mysql.default_socket    /var/run/mysql/mysql.sock    /var/run/mysql/mysql.sock
    mysqli.default_socket    /var/run/mysql/mysql.sock    /var/run/mysql/mysql.sock


    ferner noch:

    Code
    Directive    Local Value    Master Value
    pdo_mysql.default_socket    /home/vhost/WWW/var/run/mysql/mysql.sock    /home/vhost/WWW/var/run/mysql/mysql.sock

    Wie gesagt: jetzt geht alles tadellos.


    Danke nochmals für deine Beteiligung am Thread u. deine Beiträge.

    Viele Grüße

    Lin

Jetzt mitmachen!

Sie haben noch kein Benutzerkonto auf unserer Seite? Registrieren Sie sich kostenlos und nehmen Sie an unserer Community teil!