WordPress.org

Forums

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

  1. momunplugged
    Member
    Posted 7 years ago #

    I am having the same problem that everyone else seems to have!

    After 2 days of fiddling, I give up.

    I am sure of my username and pass
    I am sure server is up

    That leaves the hostname. It should be "localhost" but that doesn't work and neither does anything else I have tried in the wp-config.php file.

    Here is the exact error message:

    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?

    Here is my wp-config.php file:

    <?php
    // ** MySQL settings ** //
    define('DB_NAME', 'marybun-wordpress'); // The name of the database
    define('DB_USER', 'marybun-MomUnplu'); // Your MySQL username
    define('DB_PASSWORD', 'XXXXXX'); // ...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 am using cPanel. Host is Hostgator. The DB-NAME and DB-USER fields are exactly as they appear MySQL and I gave that username all privileges to the database etc.

    The other thought I have had is that I have not yet pointed my domain name to the hostgator name server since it is hosted on Blogger right now and I don't want to move it until my new blog is ready. So right now I log into Cpanel and the domain via my ISP address followed by "~hostgator username". I have tried putting all versions of that in for the DB-HOST, yet it doesn't seem to help. I wondered though if this situation was what was causing the mixup.

    Any thoughts? Thank you!

  2. obscure
    Member
    Posted 7 years ago #

    Can you connect to the DB using phpMyAdmin?

  3. growingthumbs
    Member
    Posted 7 years ago #

    Something is incorrect.

    I would either log into call hostgator or go to the database settings/manager. It should show the database you made along with the host name for it. If your DB name, DB user name and pass are correct. Providing wordpress with the right hostname should fix it.

  4. momunplugged
    Member
    Posted 7 years ago #

    Obscure: I see a phpMyChat in the cPanel, but no phpMyAdmin. When I click on the phpMyChat I get this message:

    Your admin has not created a cPAddons configuration yet. Please contact them and ask them to do so.

    Growingthumbs: According to the SQL Database Manager, all the settings are correct.

  5. obscure
    Member
    Posted 7 years ago #

    That leaves the hostname. It should be "localhost" but that doesn't work and neither does anything else I have tried in the wp-config.php file.

    Just double checking but are you saying this because the config file says it should be localhost or because your HOST says so? My host uses a separate DB server, as do many others. Have you actually checked with your host?

  6. macsoft3
    Member
    Posted 7 years ago #

    Are you sure you have actually assigned an account (username/password) to the database?

  7. momunplugged
    Member
    Posted 7 years ago #

    YAHOO!!! Hostgator chat solved it! I had a dash (-) instead of an underscore (_) in the username and database name. See it there in my config file?

    I fixed it and now it works!!

    Thanks so much to all of you who tried to help and offered suggestions. I am grateful to you all for your time. Have a great day!

  8. pixelburger
    Member
    Posted 7 years ago #

    I always had the correct username/password and it still did not resolve this issue for me.

    What really throws me is that when I create a new WordPress site using Fantastico (script automation), it works no problem. Migrating my site to a new location doing a full backup/restore results in the error shown at the beginning of this thread.

Topic Closed

This topic has been closed to new replies.

About this Topic