WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Error establishing a database connection (18 posts)

  1. stijnjasper
    Member
    Posted 6 years ago #

    I think I am number 1249074 with making a topic like this but i really need help. I think we all know the error:

    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.

    And this is my code:

    <?php
    // ** MySQL settings ** //
    define('DB_NAME', 'hoi'); // The name of the database
    define('DB_USER', 'doei'); // Your MySQL username
    define('DB_PASSWORD', 'dag'); // ...and password
    define('DB_HOST', 'localhost'); // 99% chance you won't need to change this value
    define('DB_CHARSET', 'utf8');
    define('DB_COLLATE', '');

    // You can have multiple installations in one database if you give each a unique prefix
    $table_prefix = 'wp_'; // Only numbers, letters, and underscores please!

    // Change this to localize WordPress. A corresponding MO file for the
    // chosen language must be installed to wp-content/languages.
    // For example, install de.mo to wp-content/languages and set WPLANG to 'de'
    // to enable German language support.
    define ('WPLANG', '');

    /* That's all, stop editing! Happy blogging. */

    define('ABSPATH', dirname(__FILE__).'/');
    require_once(ABSPATH.'wp-settings.php');

    I was adding my new blog to my ftp and I uploaded it into a folder called: wordpress. I was following this video:

    http://www.optiniche.com/blog/view.php?v=wp-install&h=472&w=773

    If you need more information just ask me ;)

    Thanks guys!

  2. obscure
    Member
    Posted 6 years ago #

    Look through your hosts documentation or contact them to confirm the DB_HOST name. I will bet money that it isn't 'LocalHost'. I think it's time the "99% chance you won't need to change this value" text was deleted from the Config file.

  3. stijnjasper
    Member
    Posted 6 years ago #

    I already fixed it. Thanks anyway :)

  4. rawblogger
    Member
    Posted 5 years ago #

    Hi Jasper,

    having the same problem on localhost MAC OSX, apache2 - what did you do?
    Cheers.

  5. whooami
    Member
    Posted 5 years ago #

    he fixed the settings.

  6. rawblogger
    Member
    Posted 5 years ago #

    makes sense :-)
    what I did was:
    define('DB_HOST', '127.0.0.1');
    and that worked fine.

  7. notphotomatt
    Member
    Posted 5 years ago #

    That didn't work for me. Mine has always been localhost and still is, but I changed it to 127.0.0.1, but it didn't work. Never had this problem before and I have been using WP since before v2.0. Now my whole site is down. I even tried creating a new db password.

  8. frothy
    Member
    Posted 5 years ago #

    Matt, did you fix yours?

    This just happened to me, and I'm positive it's something I did. The site was fine this morning, but after uploading a new theme (stupid Tarski), the database vanished. I get the "Error establishing a database connection" message (and nothing more)..

    And in my cPanel, I apparently no longer have an SQL database. I hope that simply means it can't be connected to, rather than it having been deleted...

    Here's my code in my wp-config.php file:

    <?php
    // ** MySQL settings ** //
    define('DB_NAME', 'xxxxx'); // The name of the database
    define('DB_USER', 'xxxxxx'); // Your MySQL username
    define('DB_PASSWORD', 'xxxxxxx'); // ...and password
    define('DB_HOST', 'localhost'); // 99% chance you won't need to change this value
    define('DB_CHARSET', 'utf8');
    define('DB_COLLATE', '');

    // You can have multiple installations in one database if you give each a unique prefix
    $table_prefix = 'wp_'; // Only numbers, letters, and underscores please!

    // Change this to localize WordPress. A corresponding MO file for the
    // chosen language must be installed to wp-content/languages.
    // For example, install de.mo to wp-content/languages and set WPLANG to 'de'
    // to enable German language support.
    define ('WPLANG', '');

    /* That's all, stop editing! Happy blogging. */

    define('ABSPATH', dirname(__FILE__).'/');
    require_once(ABSPATH.'wp-settings.php');
    ?>

    I tried changing 'localhost' to '127.0.0.1' and also to the actual URL, to no avail.

    I'm no programmer, so I hope there's a simple solution here..

  9. frothy
    Member
    Posted 5 years ago #

    Hm, never mind - the situation resolved itself. I suspect it had nothing to do with me or my settings and more to do with the host site itself. Woo.

  10. Anonymous
    Unregistered
    Posted 5 years ago #

    In my MacBook (10.5.4) I was having the same problem "can't connect to your database", all config data was correct, but I found there were some other problems underneath... something like a bad location for the MySQL socket (and MySQL didn't came pre-installed) in "php.ini" file (which came already installed with 10.5 with Apache and other stuff). After some Googling, this helped:

    http://foolswisdom.com/mac-wordpress-error-establishing-a-database-connection

    Hope it helps other mac-users who want to test/use wordpress in their macs!

  11. perfectDay
    Member
    Posted 5 years ago #

    Well, I've got the same problem.
    I've got apache using unusual port. So it runs on e.g 127.0.0.1:60, but when I write this in DB_HOST, it doesnt work.

    Please help if you know.

  12. perfectDay
    Member
    Posted 5 years ago #

    So, I've got it. OLD_PASSWORD trick made it!

  13. skido
    Member
    Posted 5 years ago #

    Pls some body help me out
    Am haveing the same problem and I want to know I have entered all that is need but is Error establishing a database connection
    I want to know if you have create an sql data base your self apart from the files you download from the site

  14. Samuel B
    moderator
    Posted 5 years ago #

    I want to know if you have create an sql data base your self apart from the files you download from the site

    yes - for sure
    http://codex.wordpress.org/FAQ_Installation#Do_I_need_to_create_a_database.3F
    http://codex.wordpress.org/Using_cPanel

  15. kanoor
    Member
    Posted 5 years ago #

    can i install wordpress in any free site. . . . .if yes.. .tell me which one

  16. spiderwick
    Member
    Posted 5 years ago #

  17. emilaliev
    Member
    Posted 5 years ago #

    Hi there people. I am new with WP. And I am having this infamous problem "Error establishing a database connection....+ the rest of the message". I am using concentric and it is not working with any configuration that I tried. All options possible for host, db_usename, db_name, etc. I really don;t know what else to do.

    Thank you.

  18. Lindsay Isenhart
    Member
    Posted 5 years ago #

    Error establishing a database connection

    Me too. I am currently developing a new site while i still have traffic pointed to another by the same name. My host gives me the numerical address to use to upload and view the new site while I am still workign on it. Is that why I have the problem, because there is currently another site running?

Topic Closed

This topic has been closed to new replies.

About this Topic