• hello dear phpexperts,?

    i thought that during the installation process the file wp-config-sample.php? gets to?
    wp-config.php – but this is not happening.?

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

    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.

    guess that i have to edit all the stuff manually now..?

    i want to edit the file now and i will afterwards store it as wp_config.php on the server ab.??
    Btw:?i am still wondering why this was?not happening? so far

    additionally – i will do the following?

    [QUOTE]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.[/QUOTE]

    gem. https://www.wpbeginner.com/wp-tutorials/how-to-fix-the-error-establishing-a-database-connection-in-wordpress/

    [CODE]
    define(‘WP_ALLOW_REPAIR’, true);

    [/CODE]

    [QUOTE]
    once you have done that, you can see the settings by visiting this page:?
    [/QUOTE]

    see here??https://www.yoursite.com/wp-admin/maint/repair.php??

    i come back and report all the findings

Viewing 15 replies - 1 through 15 (of 23 total)
  • Moderator t-p

    (@t-p)

    Thread Starter say_hello

    (@say_hello)

    hello dear all _ as all trials fail i have to digg deeper


    here the updates

    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:
    view sourceprint?

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

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

    well see what i get back here:

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

    well i have to muse _ what goes on here.. something goes wrong…

    i have to digg deeper

    Thread Starter say_hello

    (@say_hello)

    hello dear t-p (@t-p)

    many many thanks for the reply. I just saw your ideas – and now i will follow them and read all the infos you linked to.

    Many thanks. I come back and report all the findings.

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

    try this code, create it in utf-8 change encoding in iso-8859-1 and delete anything that starts before
    <?php
    Use only enconding without Bom

    Note* It may be that you need to modify the first parameter by adding the port localhost:8005 or change localhost with 127.0.0.1 or with the added port 127.0.0.1:8005 this port 8005 is an example

    • This reply was modified 5 years, 5 months ago by autotutorial. Reason: Add $link to mysqli_error function
    Thread Starter say_hello

    (@say_hello)

    good day dear Autotutorial – many thanks for the quick reply. This is very helpful. tried it with various versions…:

    – localhost with 127.0.0.1
    – or with the added port 127.0.0.1:8005

    and so on – did not help so far. But i will try out more.

    i will come back and report all the findings.

    meanwhile…
    have a great day

    Hi sorry I was not clear only you know what port to use, if you rely on your hosting ask them how to access.
    If everything else is managed by you go to phpmyadmin click your database and then enter this sql
    SHOW GLOBAL VARIABLES LIKE 'PORT';
    If different from 3306 you have to add it as I said before

    Thread Starter say_hello

    (@say_hello)

    hello again – first of all many many thanks – i will have a closer loook at all – and will re check all the configurations etc. etx. I also will check the paths – eg. the pipe-path to mysql…

    i come back and report all the findings.

    have a great day

    Thread Starter say_hello

    (@say_hello)

    hello again – i have gathered some more infos and insights due to some more tests.

    see the following data: – the outcome of a testscript:

    
    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:
     

    yyy see the script:

    
    <?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);
    

    some ideas:

    the paths seem to be a problem – in the config
    by the way: the character-code is 1252 ANSI L

    any idea and help – i look forward to hear from you

    regards

    Prove this SQL

    USE yourdatabase;
    SHOW GLOBAL VARIABLES LIKE 'PORT';
    SHOW GRANTS FOR CURRENT_USER;

    Into phpmyadmin.

    Thread Starter say_hello

    (@say_hello)

    on a sidenote,. …

    <?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);

    well i guess that this is saying that 1 parameter was required, 0 were provided. and besides this we surely can say that there absolutly no error checking is being done before calling the function, it’s blindly passing a variable that was collected.

    interesting: This actually makes sense, given i am probably failing to connect to mysql.?

    What we don’t see is validation that the credentials work, & i can connect.?

    one option would be to ssh to the php server, & then connect over the cli to mysql. Otherwise, we′re just guessing. Above all – we can say that there probably is no pathing issue. honestly – there are serious doubts that wordpress has a pathing issue, or this is anyway code related.

    
    active_connections ?18446744073709551563
    is this number normal? If not how can I reduce it?
    

    If this were the cause of the issue, none of the sites would work,? assuming they are all using the same mysql server. The quickest way to reduce it would be to?
    reboot the server. Just posting the number alone doesn’t tell us enough.?best ?thing would be to verify with netstat. If they are active connections,?then i probably should have a closer look a the proper firewall rules in place blocking outside connections.?

    hmm – i will have a closer look at all the condidions and settings – and will come back and report all the findings.?

    have a great day?

    Sorry the code is not correct.
    You simply need to replace mysqli_error($link) with mysqli_connect_error() for the connection error.
    This code

    USE yourdatabase;
    SHOW GLOBAL VARIABLES LIKE 'PORT';

    And

    USE yourdatabase;
    SHOW GRANTS FOR CURRENT_USER;

    the first code shows the global port number, while the second shows your privileges for the user who made the connection.
    It’s a sql you can run it in phpmyadmin, mysql etc.
    You need to replace the name yourdatabase with the name database you use for WordPress.

    Note* make sure the database WordPress user is created with local not with any host.

    Thread Starter say_hello

    (@say_hello)

    hello dear all

    many many thanks for the quick answer with all the ideas, that are very interesting.

    here a little update and more findings:

    by the way: if i do not use USE <db-name> …. then it works propperly

    conclusio: if i run

    SHOW GLOBAL VARIABLES LIKE 'PORT';

    i get a concrete output from SQL command SHOW GLOBAL VARIABLES LIKE ‘PORT’; ..

    or if i run

    
    SHOW GRANTS FOR CURRENT_USER;

    i get outputs like this one

    Output from SQL command SHOW G`RANTS 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`

    and now i have to rethink what this does want to say in the context of a – error in trying to establish a db-connection – while installing a wordpress on the frontend

    look forward to hear from you

    greetings

    sorry we are creating confusion.
    If you don’t have phpmyadmin installed please install it.
    This is an exhaustive guide to creating the database and the user with the privileges suitable for wordpress. In the field host: create the user with local and not ANY HOST. https://www.ads-software.com/support/article/creating-database-for-wordpress/#using-phpmyadmin

    Now after selecting a user other than root and clicking your database WordPress, repeat the two sql instructions and report the result without a password example

    Grants for root@localhost
    GRANT ALL PRIVILEGES ON *.* TO 'root'@'localhost' IDENTIFIED BY PASSWORD '*######' WITH GRANT OPTION
    GRANT PROXY ON "@" TO 'root'@'localhost' WITH GRANT OPTION'

    ?? … even the port.

    Thread Starter say_hello

    (@say_hello)

    hello dear autotutorial first of all many many thanks for the quick reply and the continued help that is fantastic.

    Hallo at all,

    since i am not root when running a WP installation on the web – but a dedicated dBuser

    here more insights…

    
    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 <code>jo</code>.* TO 'jo'@'localhost'
    

    i am going to deliver more data and results of db-requests.

    stay tuned – i will deliver more results

    Thread Starter say_hello

    (@say_hello)

    BY THE WAY: – My Server admin adviced me to do some extra tests;

    – running an installation with another script – a other than wordpress – to see if the installation probably would succeed with another script.

    well i am musing bout these advices – and will follow them. I must have more insights into the magic.

    will come back and report all findings.
    greetings

Viewing 15 replies - 1 through 15 (of 23 total)
  • The topic ‘Error establishing database connection – how to proceed now’ is closed to new replies.