• Resolved kspambot

    (@kspambot)


    I changed wp-config.php to have the username wordpress and the password. I am able to login to mysql using ‘sudo mysql -u wordpress -p ‘. I still get this message when I go to the url ‘localhost/wp-admin’

    Warning: mysqli_real_connect(): (HY000/2002): No such file or directory in /srv/www/wordpress/wp-includes/class-wpdb.php on line 1987

    No such file or directoryError establishing a database connection

    This either means that the username and password information in your wp-config.php file is incorrect or that contact with the database server at localhost could not be established. This could mean your host’s database server is down.

    • Are you sure you have the correct username and password?
    • Are you sure you have typed the correct hostname?
    • Are you sure the database server is running?

    If you are unsure what these terms mean you should probably contact your host. If you still need help you can always visit the WordPress support forums.

    • This topic was modified 1 week, 1 day ago by James Huff. Reason: moved to Localhost Installs, since this is a localhost install
Viewing 4 replies - 1 through 4 (of 4 total)
  • I am able to login to mysql using ‘sudo mysql -u wordpress -p ‘.

    And are you able to SELECT the configured database after logging in as this user?

    It’s not enough to have the correct username and password: also ensure that the user has all permissions on the individual database you’ve configured in wp-config.php.

    Thread Starter kspambot

    (@kspambot)

    George,

    Thanks.

    mysql> SHOW GRANTS FOR wordpress@localhost -> ;+——————————————————————+| Grants for wordpress@localhost |+——————————————————————+| GRANT USAGE ON *.* TO wordpress@localhost || GRANT ALL PRIVILEGES ON wordpress.* TO wordpress@localhost |+——————————————————————+2 rows in set (0.00 sec)

    This is my wp-config

    // ** Database settings – You can get this info from your web host ** //
    /** The name of the database for WordPress */
    define( ‘DB_NAME’, ‘wordpress’ );

    /** Database username */
    define( ‘DB_USER’, ‘wordpress’ );

    Thread Starter kspambot

    (@kspambot)

    Changed DB_HOST to 127.0.0.1 and it worked

    Glad you got this sorted.

    If you have a second to spare, kindly mark your topic as RESOLVED.

    Thank you!

Viewing 4 replies - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.