WordPress.org

Forums

Error establishing a database connection! (27 posts)

  1. Anonymous
    Unregistered
    Posted 11 years ago #

    Ive installed WordPress, fixed up a wp-config.php file with my stuff on there, but everytime i enter the index page, it comes up with this:
    Error establishing a database connection! This probably means that the connection information in your wp-config.php file is incorrect. Double check it and try again.
    Are you sure you have the correct user/password?
    Are you sure that you have typed the correct hostname?
    Are you sure that the database server is running?
    Ive tried and tried to fix it, but i cant figure out how.
    (btw im new to php)
    Please respond soon

  2. Joni
    Member
    Posted 11 years ago #

    Do you have a CPanel account? If so, go to the MySQL icon. Click there and you'll see all your databases.
    When you created your database, MySQL probably prepended your user name to the database name. For example, if your ISP's login is jsmith, and you created a database called wp1, then MySQL named it jsmith_wp1. Same thing for the user. If your user is jsmith, then MySQL named it jsmith_jsmith.
    Another GOTCHA is this: You must attach the database user to the database. This is not done automatically for you. Just use the dropdown boxes in the MySQL area to add user (whatever your username is) to your database (whatever your WP database is called), bearing in mind what I said above about the naming conventions.
    And of course, your wp-config.php file must reflect this info accurately.
    Hope this helps.

  3. Anonymous
    Unregistered
    Posted 11 years ago #

    I have the same problem. I've tried the different naming conventions. I've added my user to the database. I changed wp-config to reflect same. Any other suggestions? Does chmod need to be altered?

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

    I'm sure you'll say I'm not answering you, but have you absolutely definitely done the 'Another GOTCHA' in the post above ?
    This step catches numerous people, and until it is done, nothing will work.
    Select user in first dropdwon, select database in second dropdown, then click 'Add User to Db' below it - you need to add the combination together so the server gets the right idea.

  5. Anonymous
    Unregistered
    Posted 11 years ago #

    I'm having this problem as well. Do you think it has anything to do with the fact that I uploaded the contents of the WordPress folder rather than just uploading the folder with the contents inside?

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

    3 anons.....2 saying you have the same problem ....
    Latest anon - no, that matters not. The problem is the database connection. It does not have the correct information.

  7. Caresseh
    Member
    Posted 11 years ago #

    I too am having this difficulty. However, in my Cpanel I made sure that my username applies to my database. I made sure that I could even log into my database with my username and password. For some reason I'm still getting the "Error establishing database connection!" message.
    My database name is pokepc03_blog, and my username is pokepc03_carrie. This is what the wp-config.php code looks like (password not shown, of course):

    // ** MySQL settings ** //
    define('pokepc03_blog', 'wordpress'); // The name of the database
    define('pokepc03_carrie', 'username'); // Your MySQL username
    define('****', 'password'); // ...and password
    define('DB_HOST', 'localhost'); // 99% chance you won't need to change this value

    Do I need to define the host? That would simply be my domain name, right?

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

    // ** MySQL settings ** //
    define('DB_NAME','pokepc03_blog'); // The name of the database
    define('DB_USER','pokepc03_carrie'); // Your MySQL username
    define('DB_PASSWORD','****'); // ...and password
    define('DB_HOST','localhost'); // 99% chance you won't need to change this value

    is closer.

  9. Caresseh
    Member
    Posted 11 years ago #

    Lol, I see. Thank you!

  10. moshu
    Member
    Posted 11 years ago #

    coldsquid,
    is it possible that not only the pw has been changed on your MySQL server?

  11. coldsquid
    Member
    Posted 11 years ago #

    The site was working, then I changed the server password and got the error message when I went to check on the site.
    I then updated the password in wp-config.php, but that didn't resolve the problem. Everything else was identical. Given the advice I found here I tried changing the mySQL user names, but that hasn't worked, either.

  12. moshu
    Member
    Posted 11 years ago #

    OK, it's a dumb question, but why did you change the pw (if everyhting worked well)?
    And: how and where did you change it? Is it a hosted environment or you are hosting your site?

  13. coldsquid
    Member
    Posted 11 years ago #

    I changed the password because it was too easy to guess.
    I may not have actually change the MySQL password, I only changed the password in my cpanel server account, and someone told me that's not necessarily the same thing as the database password. (But the wp-config.php file had the old cpanel password.)

  14. moshu
    Member
    Posted 11 years ago #

    OK.
    CPanel password = basically your pw to access your account at the hosting server. (At least this is how it works in my case, and I also use CPanel.)
    MySQL password = when you create a DB user in the CPanel database admin section, you are also prompted to associate a password to that user.
    Next. You have to add that user to the DB created.
    So, my guess is you've changed some other things, too, and they are not reflected in your config file.

  15. James Huff
    Volunteer Moderator
    Posted 11 years ago #

    You should be able to find the DB_Name through whatever you used to set up your MySQL database. Ex: You webhost's control panel, phpmyadmin, etc.

  16. Eric_Fuller
    Member
    Posted 11 years ago #

    Yeah, I'm pretty much 100% sure my db_name is correct. ickyfoot is my user name, wrdp1 is the name the database was given when I first installed wordpress earlier this year. I'm totally baffled...

  17. Anonymous
    Unregistered
    Posted 11 years ago #

    Man o man. I had the d and the p switched. Figures.
    Now I'm getting this:
    Database error: [Unknown column 'post_date_gmt' in 'where clause']
    SELECT DISTINCT * FROM wp_posts WHERE 1=1 AND post_date_gmt <= '2004-12-03 14:02:59' AND (post_status = "publish") GROUP BY wp_posts.ID ORDER BY post_date DESC LIMIT 20
    My webhost thinks I need to run a db update script. I'll poke around here for an answer to that, but in the meantime, since this thread is here, anyone know how to resolve this?

  18. Eric_Fuller
    Member
    Posted 11 years ago #

    Sorry, that anon was me...

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

    Run upgrade.php again.
    What did you upload the files with, and if you have uploaded more than once, dod you first delete the files on the server ?

  20. Anonymous
    Unregistered
    Posted 11 years ago #

    If I use:
    mysql -u username -p database
    I´ll get the prompt mysql>
    and have accss to all in my db named "database"
    but i still get the msg:
    Error establishing a database connection! This probably means that the connection information in your wp-config.php file is incorrect. Double check it and try again.
    Are you sure you have the correct user/password?
    Are you sure that you have typed the correct hostname?
    Are you sure that the database server is running?
    ======================
    Note: This server is my host.
    I tried to edit my host at wp-config.php like localhost, 127.0.0.1, host.home, but it didi not work.
    I tried to edit wp-config like: username root, and didnt work.
    my wp-config:
    // ** MySQL settings ** //
    define('DB_NAME', 'wordpress'); // The name of the database
    define('DB_USER', 'blog'); // Your MySQL username
    define('DB_PASSWORD', 'pass'); // ...and password
    define('DB_HOST', 'localhost'); // 99% chance you won't need to change this value

  21. moshu
    Member
    Posted 11 years ago #

    have accss to all in my db named "database"....
    define('DB_NAME', 'wordpress'); // The name of the database

    So, is it "database" or "wordpress"???

  22. Anonymous
    Unregistered
    Posted 11 years ago #

    If you upgrade your MySql server to >= 4.1 you might get the following error:
    Client does not support authentication protocol requested by server; consider upgrading MySQL client
    This happens because the latest versions of MySql use a new format for the password (it's a longer one). In order for old clients to continue to use the newer server, you have to set the passwords on the server to their old format or upgrade your client. Because upgrading the client can sometimes be a pain, it's often easier to just update the passwords on the server.
    Run mysql and login as root:
    mysql -u root -p
    Then past the following command, editing as necessary, to change the password of the user to the old format.
    UPDATE mysql.user
    SET password=OLD_PASSWORD('somepassword')
    WHERE user='someuser'
    AND host='somehost';
    After you have set the password of the user, flush the tables.
    flush privileges;
    Then exit the mysql client with "quit" and you are set.
    See http://dev.mysql.com/doc/mysql/en/Password_hashing.html for more information on this issue.

  23. Anonymous
    Unregistered
    Posted 11 years ago #

    Anonymous!! =]
    thank u.
    _winstroll.

  24. Anonymous
    Unregistered
    Posted 11 years ago #

    good!

  25. itzapizza
    Member
    Posted 11 years ago #

    I use Yahoo! as the host and had the Error establishing a database connection! issue for 24 long hours.

    The way I fixed it was by changing the hostname from localhost to <b>mysql</b>

    define('DB_HOST', 'mysql'); // 99% chance you won't need to change this value except with Yahoo!

  26. alexabbas
    Member
    Posted 11 years ago #

    I installed on a Mac, and I had this common "database connection" problem, and it turned out to be caused by my version of MySQL being too new. I downgrading it to 4.0.23-standard and that fixed everything.

    Here's my site: Sprocket :-)

    Alex

  27. agnese
    Member
    Posted 11 years ago #

    For example, if your ISP's login is jsmith, and you created a database called wp1, then MySQL named it jsmith_wp1.
    how i can retrieve this [????_wp1] information?
    i have the MySQL administrator tool...

    it show:

    Server istance:
    username: root
    hostname: localhost
    port: 3306
    server---
    mysql version: 4.1.9-nt TCP/IP
    network name: localhost
    IP: 127.0.0.1
    client---
    Version: 5.0.0
    Network name: cippalippa
    IP: 192.164.0.25
    Operating System: WinXP
    Hardware: AMD etc etc

    where is my jsmith?
    and how can i retrieve it?
    thank you a lot...
    *apple*

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.