Ready to get started?Download WordPress


[resolved] Database connection problem (24 posts)

  1. redtruck
    Posted 9 years ago #

    I had WordPress installing with one click through cPanel on an Apache server, then it stopped working. After several efforts to find help on the cPanel forum, my hosting techs and this forum, I decided to start with a fresh install in a fresh hosting account. When run the wp-admin/install.php program, I get the "Error establishing a database connection" error. My server is up. I've double-checked the database name, username, password, and the host name is "localhost." PHP Version is 4.3.11, MySQL Version is 3.23.49, Zend Version is 2.5.7. Permissions for the 4 wp- folders is 755. Permissions for the files are 644. suexec is disabled. I don't know what other information to give you. WP worked before on this server with one-click installs. Now it doesn't work at all. MySQL is working for other applications I have on this server. If I need to check anything else on this server, please give specific instructions. I really appreciate any help you can give me. Thanks, Bob

  2. Class
    Posted 9 years ago #

    Did you create the wp-config.php file? Edit it? What permissions does it have?

  3. Mark (podz)
    Support Maven
    Posted 9 years ago #

    " then it stopped working"
    What did ?
    What did you see ?

  4. redtruck
    Posted 9 years ago #

    To Class,
    Many thanks for responding.
    I edited the wp-config-sample.php file per the instructions as follows:
    define('DB_NAME', 'scrubsfi_wp1');
    define('DB_USER', 'scrubsfi_wp1');
    define('DB_PASSWORD', '**obscure**');
    define('DB_HOST', 'localhost');
    being careful not to delete any punctuation. I've checked the names to be sure they are the same as are indicated in the MySQL section of my cPanel. Then I changed the file name to wp-config.php . It's permissions are 644.

    If you need access to the cPanel of this hosting account to help further, I can provide access information. I need to know what steps you take to resolve the problem as I have another account to correct.

    Thanks again, Bob

  5. Class
    Posted 9 years ago #

    Hmm, do you have shell access? If so, could you try a "mysql -u scrubsfi_wp1 -p" ?
    I'm kinda lost without a shell prompt :)

    Does db scrubsfi_wp1 exist? From the previous working WP?
    Do you have access to db and http error logs?

  6. redtruck
    Posted 9 years ago #

    To podz,
    Many thanks to you for your response as well.
    When I said "then it stopped working" I was referring to the one-click installation through my cPanel. I had to reinstall WP so I deleted the hosting account, then created the hosting account again and attempted the one-click installation process through my cPanel as before. The resulting page says this:
    "WordPress 1.5 Setup
    We are installing in /home/username/public_html/blog...
    Moving installation files into place...Done
    Setting up config file...Done
    Finishing installation steps...Done
    Installation Finished
    To access your WordPress installation go to: http://domain.com/blog/
    To access the admin area of your WordPress installation go to: http://domain.com.com/blog/wp-admin/
    The default randomly generated username and password are:

    BTW, the actual version installed through this one-click process was
    The exceptions I noted were:
    1. The wp-config.php was not present or setup with database info as reported. An unedited wp-config-sample.php was in the /blog folder but not the correct and complete wp-config.php as before.
    2. The MySQL database, user and password were not setup as before.
    3. No "default randomly generated username and password" was not provided as before.

    I tried creating a new MySQL database with a new user and password, editing this information into the wp-config-sample.php, renaming it to wp-config.php, then running the wp-admin/install.php but this resulted in the same "Error establishing a database connection" message.

    So I deleted the blog folder, downloaded ver from this site, uploaded it to my site, edited and renamed the wp-config.php and got the same result: Error establishing a database connection.

    As I mentioned, I have another application in a different domain on this server where MySQL databases are running just fine. So I believe MySQL is running okay on this server. If there's some other way for me to test whether MySQL is connecting in this domain, or if I can provide any other info, please let me know.

    Thanks for your help, Bob

  7. Mark (podz)
    Support Maven
    Posted 9 years ago #

    If you use CPanel / vDeck or Plesk, there are 3 guides on that page.
    If you use something else, tell us what it is and we should be able to sort it.

    It's very probably just one button that needs clicking.

  8. redtruck
    Posted 9 years ago #

    Hi Class, If you're not on the other side of the world from me, you're up awful late. Thanks for such a quick response.

    1. Shell Access. I have shell access through root. But when I tried to setup the MySQL databases through the shell, it rejected my root password and expected a master MySQL password which I don't have. I'll request from my host.

    2. "Does db scrubsfi_wp1 exist?" Yes. After the I got the "Error establishing a database connection" I've deleted the blog folder, left the databases intact, downloaded ver from this site, uploaded it to my site, edited and renamed the wp-config.php and got the same result. Then I also tried deleted the hosting account, then created the hosting account again, setting up the MySQL databases fresh through the cPanel, uploading, editing and renaming wp-config-sample.php and I still get the same result.

    Do you know how I can find the master MySQL password for this server (it is mine, albeit hosted offsite) with root access?

    Do you know if there is any problem to my changing the MySQL password for this server (which I believe I can do through my WebHostingManager access), in which case I would know the password and be able to carry out your shell command. Or would this disrupt other MySQL applications running on this server?

    3. "Do you have access to db and http error logs?" With shell access through root, I'm sure I do but I don't know what I'm looking at or looking for. I know just enough to be dangerous. But I follow instructions well. Sorry.

    Thanks, Bob

  9. redtruck
    Posted 9 years ago #

    Thanks for the Tamba2 link. I was following those exact instructions. However, your direction on confirming "localhost" led me to look more closely at the connection string for PHP. I put this string in a copy of index.php and called it with my browser and got this mysql_error message: "Client does not support authentication protocol requested by server; consider upgrading MySQL client".

    A further search on Google rendered information at: http://dev.mysql.com/doc/mysql/en/old-client.html which relates to versions of PHP, MySQL and client libraries and starts to point back to potential problems with my server. While I'm sure my other MySQL driven applications are working, I'll address this to my hosting techs and report back anything I find out. Bob

  10. scarfy007
    Posted 9 years ago #

    This exact thing happened to me thirty seconds ago. Now I can't get the database to connect. I'm confident the database names are correct and my config.php is edited properly. I can't believe it but this is my exact problem step for step. Have you found anything out?

  11. Mark (podz)
    Support Maven
    Posted 9 years ago #

    If your blog was working, and you've changed nothing, but you then see a database connection error, don't worry.

    Your host will have caused this, and it can occur for a number of reasons. Give it 15 minutes, after that, email your host asking them what is happening on the server. Server maintenance / upgrading can all cause this temporary blip and it's not a WP fault.
    It also happens to pretty much everyone at some stage :)

  12. scarfy007
    Posted 9 years ago #

    Thanks for the quick response! I will chill for a bit... glad its nothing I did.

  13. redtruck
    Posted 9 years ago #

    Hi All,

    I don't know where to suggest that this be made sticky or put in the FAQ or what, but it boils down to this: Failure to connect to the MySQL database isn't always a user typing problem. So if you are absolutely certain that:
    1. you set up your MySQL database correctly
    2. you set up your MySQL user and password correctly
    3. you added your MySQL user to your MySQL database correctly
    4. you edited your wp-config.php to include your DB_name, DB_user, DB_password and DB_host correctly

    and still, when you attempt to run the install.php program, you get the dreaded "Error establishing a database connection," go directly to your host and tell them you're not able to connect to a simple MySQL database with a simple PHP program.

    If they point to WordPress and declare that they're not responsible for making WordPress work, if you're using cPanel, go back to your cPanel, and click on MySQL and look for the "connection strings. Copy the PHP connection strings into a text file and add some PHP stuff around it thusly:

    $dbh=mysql_connect ("<HOST NAME HERE>", "<USERNAME HERE>", "<PASSWORD HERE>") or die ('I cannot connect to the database because: ' . mysql_error());
    mysql_select_db ("<DB NAME HERE>");

    The HOST NAME, USERNAME and DB NAME should already be filled in correctly from your cPanel/MySQL display. Fill in your PASSWORD where indicated. Then save this file as a PHP file with a name like mysql-test.php. Upload it to your hosting account. I'd suggest you put it in your "document root." Then open your browser and go to: http://www.yourdomainname.com/mysql-test.php
    If you get an error message, take that to your host and say "This doesn't have anything to do with WordPress, I can't connect to a simple MySQL database on your server with a simple PHP program." This takes WordPress out of the picture and gives your hosting company a relevant error message to work with.

    Further, if the error message is: "Client does not support authentication protocol requested by server; consider upgrading MySQL client." refer your hosting company to:

    Hope this helps. Many thanks to all for their help. Bob

  14. oleum
    Posted 9 years ago #


    I'm having a similar problem. I uploaded a test like the one above and I don't get an error message (the root directory on my hosted account). WordPress still gives me an error message though its installed in a subdirectory. I've deleted the whole lot at the moment and am about to upload again. Anything else I can try if it still doesn't work. I am considering binning the lot and using something else. I have an old b2 I could rework already installed if I have to.

  15. Class
    Posted 9 years ago #

    What error message does WordPress give?

  16. fundog5
    Posted 9 years ago #

    I am having the same problem, continually receiving the "Error establishing a database connection" message even though I've:
    1. confirmed the MySQL database name
    2. confirmed the MySQL user name & privileges
    3. confirmed the db user password was correct & verified MySQL was up & running properly through phpMyAdmin
    3. confirmed the db host name was correct, doubly verifying with my web account host (websitesource.net)
    4. ran a manual password reset via SQL
    5. successfully run the simple "mysql-test.php" connection script from both the root directories and the subdirectory where I'm attempting to install WP

    So I'm also totally stumped. What to do?
    (btw, my host runs MySQL 4.0.24 and PHP 4.3.11)

  17. fundog5
    Posted 9 years ago #

    Since this thread is marked "resolved," would I be better off posting my issue in a new thread? I've followed the codex to the letter, have confirmed necessary configs with my hosting service and have validated simple PHP-MySQL connections. I don't see what else could be wrong unless there's something up with this build of WP and the specific versions of MySQL and PHP I'm using. Any assistance that can be provided would be greatly appreciated.
    thanks- Jed

  18. Mark (podz)
    Support Maven
    Posted 9 years ago #

    Jed - do you use cpanel / vdeck / plesk / ensim ?

    It's probably that the database and database username have not been connected.

  19. fundog5
    Posted 9 years ago #

    Thanks for the reply, Podz.

    According to the host's documentation, they use H-Sphere control panel system, not any of the 4 you've mentioned.

    Unless I'm mistaken, I'm pretty sure the user has been correctly connected or "added" to the database- I can login to the database using the username and password I setup initially and run SQL queries on the database through phpMyAdmin. Am I missing something else? Should I try starting from scratch again?
    Thanks again.

  20. Mark (podz)
    Support Maven
    Posted 9 years ago #

    I can't see what you are missing - you look to have worked through it all, and as such you could try a reinstall but you may hit the same wall.
    Has any whitespace crept into the data above ?
    Can you ask your host what data they would complete without telling them what you have done (so they actually look rather than just saying "Yeah that looks right")

  21. fundog5
    Posted 9 years ago #

    I'll try a session with websitesource and see what they say. Otherwise, I'm open to letting you poke around in my host account, if necessary.
    - Jed

  22. Mark (podz)
    Support Maven
    Posted 9 years ago #

    If you want to email me - tamba2 @ gmail . com


  23. fundog5
    Posted 9 years ago #

    Hi. Me again. So now the story gets more convoluted... I was using DreamWeaver to upload files through its built-in FTP tool, and I think it wasn't sending properly. The wp-config.php file I had on my host was totally wrong. Even so, after having changed it (through another channel) and verified that it looks correct, I still can't get WP to not give me the "error connecting" msg.

  24. fundog5
    Posted 9 years ago #

    Issue resolved. I went into my control panel and changed the db user's password to something simpler and did the same in the wp-config.php file. It seems to have rectified whatever issues were causing the script to fail in the past. Thanks for all of your help, Podz.

Topic Closed

This topic has been closed to new replies.

About this Topic