Error in Establishing a DB-Connection in WP-Installation - Pfad-Probleme am Server

say_hello

say_hello

Dauergast
189
hallo und guten Abend,

hier geht es um die Installation einer Wordpress auf einem Server - und den hier gemachten Meldungen und Fehlermeldugnen : eigentlich müsste sich beim Installationsvorgang die Datei wp-config-sample.php zu wp-config.php umsetzen. Das passiert aber nicht.

Error establishing a database connection
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.

hier hab ich folgende weitere Befunde: --- beim Installationsversuch

Code:
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.
Click to expand...

Ich habe ferner versucht danach mal manuell die Datei zu editieren u. speicherte
die dann als Wp_config.php auf dem Server ab.
Btw: wundert mich etwas, dass dies nach mehreren Versuchen nicht von alleine geschrieben wurde - die wp-config.php

Darüber hinaus: was ich auch darüber hinaus noch gemacht habe:

entsprechen einer Anleitung auf WP-Beginner:
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.

ich habe also noch folgende - in der Anleitung gegebene Maßnahme verfolgt:

gem. How to Fix the Error Establishing a Database Connection in WordPress

Code:
define('WP_ALLOW_REPAIR', true);

nachdem die obigen Aktionen nicht zum Erfolg geführt haben - und sich nichts ändert versuche ich weiters....:How to Fix the Error Establishing a Database Connection in WordPress

den Einsatz eines Test-The-Connection-Scripts:

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

Doch - 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.

Wie oben bereits geschrieben - habe ein Testscript eingesetzt dass helfen sollte die DB-Verbindung zu überprüfen - es gibt diese Ergebnisse zurück:

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:


Also - in der Deutung der Ausgabe des Scripts - denke ich dass der Pfad nicht passt
und nun überlege ich ob denn ggf. hier etwas nicht passtl:


Code:
     * For information on other constants that can be used for debugging,
     * visit the Codex.
     *
     * @link https://codex.wordpress.org/Debugging_in_WordPress
     */
    define( 'WP_DEBUG', false );
 
    /* That's all, stop editing! Happy publishing. */
 
    /** Absolute path to the WordPress directory. */
    if ( ! defined( 'ABSPATH' ) ) {
        define( 'ABSPATH', dirname( __FILE__ ) . '/' );
    }
 
    /** Sets up WordPress vars and included files. */
    require_once( ABSPATH . 'wp-settings.php' );

Hmm - ich denke dass ich das Testscript u. deren Ergebnisse richtig deuten muss.


update: noch ein paar weitere Befunde:

habe nnoch 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:


Code:
<?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:)

say
 
Zuletzt bearbeitet:
hallo und guten Abend,

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


Code:
<?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.
 
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


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.
 
hallo und guten Tag

vorweg: - 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 Community,


jetzt geht alles wieder: 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.



Viele Grüße
 

Ähnliche Themen

W
Antworten
37
Aufrufe
1.405
NebulaOne
NebulaOne
DOT2010
Antworten
4
Aufrufe
166
DOT2010
DOT2010
say_hello
Antworten
0
Aufrufe
342
say_hello
say_hello
Zurück
Oben Unten