Forums

[resolved] MySQL connection (9 posts)

  1. riverkash
    Member
    Posted 7 months ago #

    First of all, I have phpmyadmin installed and working fine.

    My problem...
    I have just installed the latest version of WP and when I go to http://localhost/wp/wp-admin/install.php I get the Error Establishing a database connection screen. The connection details within my wp-config.php file are correct and match phpmyadmin.

    Does anyone have any ideas?

  2. RichardWPG
    Member
    Posted 7 months ago #

    You might need to check your database credentials with your hosting provider

  3. riverkash
    Member
    Posted 7 months ago #

    Just to add to this, I can also connect to MySQL from the CLI (Command Line Interface) using Terminal.

  4. danhgilmore
    Member
    Posted 7 months ago #

    Do you get "Error Connecting to Database"? If so, open wp-includes/wp-db.php and after the line

    if(!$this->dbh) {

    add this:

    echo(mysql_error());

    That will display your true error

  5. esmi
    Theme Diva & Forum Moderator
    Posted 7 months ago #

    Do not edit core files. Check your server error logs instead.

  6. Ipstenu
    Half-Elf Support Rogue & Mod
    Posted 7 months ago #

    On localhost you have define('DB_HOST', 'localhost'); in your wp-config, and no port number?

  7. danhgilmore
    Member
    Posted 7 months ago #

    True, you shouldn't edit core files, but if you don't have access to said server error logs, my code would help. Maybe I should have put a disclaimer stating that editing core code is not recommended and should be reverted ASAP

  8. esmi
    Theme Diva & Forum Moderator
    Posted 7 months ago #

    Maybe I should have put a disclaimer

    Yes - you should.

  9. riverkash
    Member
    Posted 7 months ago #

    Thanks everyone for your support, I have rectified the problem.

    Due to the nature of of my "/etc/hosts" file, the localhost was not working in the wp-config.php.

    In the wp-config.php I replaced localhost with "define('DB_HOST', '127.0.0.1');" and now have a database connection.

    Once again thanks to all that helped with this.

Reply

You must log in to post.

About this Topic