• Yes, I know this is a common problem but I really am stuck. On step 5 of the wordpress install I am getting: Error establishing a database connection
    My wp-config.php currently reads:

    /** The name of the database for WordPress */
    define(‘DB_NAME’, ‘name_correctinfo’);

    /** MySQL database username */
    define(‘DB_USER’, ‘name_correctinfo’);

    /** MySQL database password */
    define(‘DB_PASSWORD’, ‘correctpassword’);

    /** MySQL hostname */
    define(‘DB_HOST’, ‘localhost);

    I am using Cpanel and YES I have confirmed that all info matches and is typed correctly. YES I have added the correct user to the correct database and YES I have confirmed that my host uses ‘localhost’ as the Mysql name.

    The four basic infos of dbname/username/password and hostname are all matching, correct and properly assigned. I have deleted and recreated both user and database several times (as has been suggested) with the same information, but no effect.
    So it really is something else this time!

    Other details: I already have another wordpress running on the same host (yes, I know wordpress is multisite as standard now but I couldn’t get a network running for other reasons) so this is a second concurrent installation. The live installation is in my root directory, but this one second one is in a subfolder which is named something other than ‘wordpress’ (that shouldn’t matter?) I uploaded it there via ftp.

    Any (new) ideas?

    Thanks.

Viewing 10 replies - 1 through 10 (of 10 total)
  • Hi !

    I’m relieved to see I’m not the only one with this specific issue.

    I also have double-checked these places and been over recreating a database and a user, but same here: no database connection. Only difference with my configuration is, I don’t have a double installation of WordPress, this issue comes up and this is my first install of WP.
    I’ve also found a suggestion of modifying the php.ini file to activate (uncomment) the mysql module, but to no avail.

    Any help coming our way ? Spite, do you have any suggestions ?

    Thanks in advance.

    Thread Starter spiteyourface

    (@spiteyourface)

    No suggestions, binomiale and still stuck my end. All help very welcome.

    @spite the line

    /** MySQL hostname */
    define(‘DB_HOST’, ‘localhost);

    is missing the ‘ after localhost

    could that be the problem?

    Thread Starter spiteyourface

    (@spiteyourface)

    Well spotted maoski, thanks. But that is only an overhang from my retyping/trying alternative host names. Therefore the problem predates that mistype and subsequently, has still made no difference.

    what if you copy the wp-config.php from the working WP and just change the table prefix?

    Thread Starter spiteyourface

    (@spiteyourface)

    Good lateral thinking brasofilo (slaps head) That shouldn’t rightly have made a difference if the input data was already right, but as a matter of fact – it fixed it! (for noooooooow)

    What actually happened was I did as brasofilo suggested, which took me through to the next stage of the installation set up. I added my details, it bought up that smug little ‘expecting more steps?’ message and declared itself installed, so I clicked ok and… ERROR ESTABLISHING A DATABASE CONNECTION.

    oh.

    Thinking the active wp-config.php probably had some changes in it from various customizations on my other site, I instead replaced it with a fresh new config.php adapted from the wp-config-sample.php file that comes in the installation zip. Even though this is exactly how I generated the first one in the first place.

    The data I entered was definitely correct across all three or more versions/attempts so (as indicated by the latter hiccup) there must have been something astray in the rest of the dynamics of that file?

    Anyway, all I can tell you is that swapping it out for a new file generated from the sample file, fixed it on this occasion.

    Many thanks all!

    How’s everything mate? Got it all fixed?

    The @spiteyourface solution isn’t really a solution, as it won’t work if you don’t have a handy functioning wordpress installation to borrow from.

    I’m stuck on this too. Here’s a clue, I ran this little php script to test my database connection and IT failed!

    $db = @mysql_connect(‘localhost’, ‘root’, ‘Password’);
    if (!$db) echo “connection failed”;
    else echo “connection succeeded”;

    However, the XAMPP control panel reports that MySQL is running.

    I’m confused. I know where the wordpress config.ini is to set what database to look for.
    Where is the database’s config file, where its user/password is set?
    Is this done in phpmyAdmin, by setting up a user/password for a specific database? Or is there another level of passwords for mysql itself that I need to match up?

    :<)Thanks!

    I had a similar problem connecting to mysql on localhost. I can connect to the database on localhost using mysql command line client but get connection failed with WordPress.

    Using 127.0.0.1 as the hostname in the wp-config.php file fixed it for me.

    I thought I was having a problem with ports, so I tried setting the port for the mysql database. But this got to complicated. YOu have to go into the Apache server setup and change it there. I got all twisted up and finally realized I didn’t know what I was doing.

    What if finally boiled down to was that I did not have the user name and password right. I did have to reinstall XAMPP to undo all the changes I made to ports. But after the reinstallation, I created an empty database in phpmyadmin. Then I did an import of the tables from my remote site.
    This worked. After importing, if you import the “options” table, you do have to go into wp-admin and change the database location to localhost. If the local host connection has the database connection problem here, open up wordpress/wp-config.php. You’ll see the fields where you set up your user/password and database name and host. I’m using the numerics for localhost here, ‘127.0.0.1’ but ‘https://localhost&#8217; is supposed to work as well.

Viewing 10 replies - 1 through 10 (of 10 total)
  • The topic ‘Error establishing a database connection’ is closed to new replies.