WordPress.org

Ready to get started?Download WordPress

Forums

Error establishing a database connection (25 posts)

  1. hd198871
    Member
    Posted 5 years ago #

    about install 7.1 wordpress......
    i am sure that i fill in the right db user name and s-code
    but......
    help!!thanks a lot!!!

  2. khmedia
    Member
    Posted 5 years ago #

    please tell us clearly ... actualy what happened and what is the error shown by wordpress install. Post the error here.

  3. grandsorcier
    Member
    Posted 5 years ago #

    I have a similar issue:
    - I have downloaded the latest wp-release
    - I've installed mysql (5.1.31) locally on my macbook pro (os x 10.5.6) and have set up a database with a user that has full rights on the db.
    - I've (renamed and) edited the wp-config.php file.
    - I've enabled web sharing
    - As DB_HOST I have tried both 'localhost' and the hostname of the computer's website from the web sharing dialog in system preferences.

    I've previously set up wordpress for my externally hosted website, which was a breeze btw. I'm starting to suspect it might have something to do with how the db is set up on my local machine, but I haven't being able to solve it by googling for it.
    Any and all advice will be appreciated.

    And yeah, I get the same 'error establishing a db connection' message as hd198871.

    Thanks,

  4. D M
    Member
    Posted 5 years ago #

    @grandsorcier

    Did you install MySQL onto your harddrive directly or did you install Xampp first, which btw comes with MySQL?
    I have Xampp (complete with MySQL) installed on another computer which I use for developing the sites and it was a breeze.

  5. hd198871
    Member
    Posted 5 years ago #

    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 DB_HOST. 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?

  6. hd198871
    Member
    Posted 5 years ago #

    why i get creay!!!!!!
    have you been suffer it before???

  7. Len
    Member
    Posted 5 years ago #

    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 DB_HOST. 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?

    Error message is self-explanatory. Either the database server is down or you've entered the wrong details.

    why i get creay!!!!!!
    have you been suffer it before???

    ?

  8. backentoft@gmail.com
    Member
    Posted 5 years ago #

    @LenK
    Well thanks for contributing nothing. Your smug comment sure helped alot. Idiot.

    @EloquentBohemian
    I'll have a look-see at xampp, thanks for the advice.

  9. D M
    Member
    Posted 5 years ago #

    @grandsorcier & backentoft@gmail.com

    The Xampp is different if you install on Mac or MS Windows.
    Read the WP Codex here

  10. Len
    Member
    Posted 5 years ago #

    @backentoft@gmail.com

    Smug? Hardly. I quoted the first part of the question because the error message is self-explanantory. You'd be amazed how many people post that message in this forum believing they have entered the correct details when in fact they didn't. Point I was trying to make is re-check the details to be absolutely certain so that that possibility can be removed before moving on to something else.

    I quoted the second part of the question and replied with a "?" because I didn't understand what he was trying to say.

    If hd198871 thinks my response was smug then I apologize for it wasn't meant to be. As for you I could care less how you take my responses. Have a nice day.

  11. backentoft@gmail.com
    Member
    Posted 5 years ago #

    See, it wasn't that difficult to be polite now was it?

    It doesn't change the fact that I perceived your reply as being smug. Just to quote someone's message and basically ask him/her if (s)he's too stupid to read isn't helpful. If you were really trying to help you could have made more of an effort. Myself being "technically challenged", I kind of depend on helpful people in forums like this when my google imagination runs out, and there are usually lots of good people that understand how difficult it can be at times and just go that extra distance trying to be helpful.

    "...that possibility can be removed before moving on to something else.". Now a suggestion on what that "something else" could be, THAT would have been very helpful. I don't know about hd198871, but I'm still stuck exactly where I was yesterday. And by the looks of it, not moving either.

  12. cdkotran
    Member
    Posted 5 years ago #

    Well, I'm having the same connection issue listed above of 'Error establishing a database connection' and to assist in trouble shooting I have created a small PHP script on the same server as WordPress with the same connection information. The test script works yet WP does not.

    Any other thoughts?

    CK

  13. cdkotran
    Member
    Posted 5 years ago #

    Ok, it would appear that the randomly generated password by phpMyAdmin is to long for the config creation tool in WP to handle because when I change the password from 'AYZXLe3ZvfKAdeum' to 'test' the config file is then generated. If I then change the password in the config file back to 'AYZXLe3ZvfKAdeum' (and back to on the DB server) the install portion is ok with it. I might suggest someone (not me - no time) inspect the config file creation code for a password limit bug.

    CK

  14. Len
    Member
    Posted 5 years ago #

    @backentoft@gmail.com

    You ought not perceive anything in an arena such as this. Text is a poor medium to convey emotion and as such you have no idea of my intentions or motivations. Assumptions are unwise. Anyway, enough of this nonsense and back to the problem at hand.

    The only things I can think of (and I'm being redundant I know) is make absolutely sure database name and database user are correct. Some hosts preface the database name with your username such as username_databasename. Make sure said user has been added to the database with necessary privileges. On most hosts (but not all) the database host is localhost. Double check that. Beyond that I'm out of ideas. Hopefully someone else with a fresh set of eyes will pop in.

  15. khmedia
    Member
    Posted 5 years ago #

    Try opening the PhpMyAdmin and check your database password and username. If possible try posting your config.php file here (but without username and password, i hopt u understand what is security?)

    Awaiting...

  16. backentoft@gmail.com
    Member
    Posted 5 years ago #

    @hd198871
    I finally managed to solve the issue by using the localhost IP-address "127.0.0.1" instead of 'localhost' for 'DB_HOST' in wp-config.php. Weird considering that this IP-address is mapped to localhost anyway...?

    Hope this helps.

  17. khmedia
    Member
    Posted 5 years ago #

    @hd198871
    I finally managed to solve the issue by using the localhost IP-address "127.0.0.1" instead of 'localhost' for 'DB_HOST' in wp-config.php. Weird considering that this IP-address is mapped to localhost anyway...?

    Hope this helps.

    I couldn't get u.

  18. gnagent
    Member
    Posted 4 years ago #

    I had the same problem on a local OSX 10.5.7 install with MySQL 5.0.67 and Apache 2.2. It was pretty clear that WordPress was at fault, because phpMyAdmin was working just fine in the same doc root using the same MySQL user.

    I had to change from "localhost" to "127.0.0.1" for "DB_HOST" in wp-config.php to get it to work. Sort of ridiculous, since I can actually access the site at http://localhost/wordpress/wp-admin/install.php after making this change. Given that "127.0.0.1" can't fail as a substitute for "localhost", it seems like wp-config-sample.php should be permanently changed to use the IP address rather than the hostname.

  19. gbulmash
    Member
    Posted 4 years ago #

    Actually, my problem may be due to Snow Leopard and the fact that there are all sorts of quirks and issues with installs of packages intended for Leopard.

    I can get phpMyAdmin and a GUI MySQL manager to connect to the database via the socket method, but can't connect via TCP to localhost, the hostname, or 127.0.0.1. So, since WordPress requires a host name, I can't make it connect.

    I think I may clear the current install and compile MySQL from source. Also heard that the latest 5.4 beta worked nicely on Snow Leopard.

  20. gbulmash
    Member
    Posted 4 years ago #

    Installed 5.4 beta and was able to get direct localhost connection via the GUI client, but not via WordPress. I tried both Localhost and 127.0.0.1 to no avail. Finally tried 127.0.0.1:3306. Voila, WordPress is up and running.

  21. pneal
    Member
    Posted 4 years ago #

    I am having exactly the same problem connecting to my database. I'm running Snow Leopard with a custom build of the 64bit MySQL. I've a clean install of wordpress 2.8.4.

    I've configured the database. I can connect via the terminal and via sequel pro. All of the passwords work correctly. With sequel pro I'm connecting at localhost.

    I've tried setting the MySQL host name to:

    localhost
    localhost:/tmp/mysql.sock
    localhost:3306
    127.0.0.1
    127.0.0.1:3306

    None of which was to any avail. Help anyone?

  22. Aaron T. Grogg
    Member
    Posted 4 years ago #

    to anyone still having trouble: try a variety of options, these must vary with WP versions...

    when you're dealing with this block in wp-config.php:
    define('DB_NAME', 'wordpress'); // The name of the database
    define('DB_USE'’, 'root'); // Your MySQL username
    define('DB_PASSWORD', ''); // …and password (Leave empty!)
    define('DB_HOST', 'localhost'); // Your MySQL hostname

    DB_NAME: you should change this (if you're creating a local version of an online WP install, this is the same name you were given when you created the online version of the database, something like abc12345678901234).

    DB_USER: this seems to vary, some sites say use the username you chose when installing the online version, others say leave it as "root"; "root" is what finally worked for me.

    DB_PASSWORD: also seems to vary, one site said use your existing password from the online install, but most said leave it blank; leaving it blank worked for me.

    DB_HOST: another varying item, some say leave as "localhost", others had to specify an IP Address (most often seen: 127.0.0.1).

    and last but not least, my version of WP (2.8.4) does NOT have a /wp-admin/install.php, mine is /wp-admin/install-helper.php, which, after running, just left me staring at a blank white page... i then manually went to /wp-admin and was greeted by a glorious log-in screen...

    hope this helps someone,
    Atg

  23. asaintprix
    Member
    Posted 4 years ago #

    I've tried all of these things and still can't get WP to work. Granted, I'm on an old version of the software and that could be part of the problem - perhaps it's time to upgrade after all. I'll try that and report back.

  24. broughten
    Member
    Posted 4 years ago #

    Like gbulmash, I also had to supply the port in the hostname config and I'm also running snow leopard. ::anger:: ::rage::

  25. mjname
    Member
    Posted 4 years ago #

    I have several blogs and they all connect and they all use the same database with different table prefix's

    I have installed a fresh copy of 2.9.1 and I can't connect and have even copied the the top part of the wp-config.php to no avail.

    totally bizarre

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.