Forums

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

  1. vixenk
    Member
    Posted 6 years ago #

    I'm new to WordPress, and actually new to databases and php in general.

    For some reason I can't seem to get my config file right, because every time I try going to the install file I get a "Error establishing a database connection" error.

    I created a database in mysql and a user account with all permissions enabled. I uploaded WordPress to a "test" directory folder seperate from my site *i.e. http://blah.net/blah/testfolder*. In the config file I followed the read me and in file instructions and entered the database name, username, and password. When it didn't work I tried changing the host location from localhost to the actual hosts address for my database, and that didn't work either.

    My config file basically looks like this:

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

    // Change the prefix if you want to have multiple blogs in a single database.
    $table_prefix = 'wp_'; // example: 'wp_' or 'b2' or 'mylogin_'

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

    /* Stop editing */

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

  2. vixenk
    Member
    Posted 6 years ago #

    LOL, sorry, minus the 'CODE' tags, I was worried that the code I was entering wouldn't show up as text.

  3. vkaryl
    Member
    Posted 6 years ago #

    Without knowing where you're hosted etc. about the only thing I can see offhand is that "hostname_password" wouldn't necessarily be a password with "hostname" prepended to it with the underscore. Your password should be entered in that field "bare" - exactly as you set it up when you created the db.

  4. vixenk
    Member
    Posted 6 years ago #

    *nods* I thought of that as well, and tried everything exactly the way it was done in phpmyadmin, with the pw being stripped of the whole hostname and underscore thing, then I tried stripping all of it of the hostname and underscore thing... none of it worked either. :(

  5. vixenk
    Member
    Posted 6 years ago #

    So I tried again, this time this is what it looked like, and this is the actual file word for word *except for the password*...

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

    // Change the prefix if you want to have multiple blogs in a single database.
    $table_prefix = 'wp_'; // example: 'wp_' or 'b2' or 'mylogin_'

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

    /* Stop editing */

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

  6. moshu
    Member
    Posted 6 years ago #

    Many hosts have quite specific requirements for the DB_HOST line... Did you check with your host about these 4 pieces of info?

  7. vixenk
    Member
    Posted 6 years ago #

    I tried entering the host location in here, but other than that, no, I will try that now. :)

    What four pieces of info do I need?

  8. vixenk
    Member
    Posted 6 years ago #

    Nevermind, I finally got it to work. :)

  9. vkaryl
    Member
    Posted 6 years ago #

    Please tell us what you did, so that someone searching may also find the solution!

    Thanks!

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.