Cannot Connect to database (10 posts)

  1. vaujanolo
    Posted 5 years ago #

    I can see this had been covered before but I haqve spent the last six hours trying to resolve this and cannot get anywhere:

    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?

    My settings are:
    define('DB_NAME', 'mynews'); // The name of the database
    define('DB_USER', 'mynews'); // Your MySQL username
    define('DB_PASSWORD', 'Kup9xagu'); // ...and password
    define('DB_HOST', 'localhost'); // 99% chance you won't need to change this value
    define('DB_CHARSET', 'utf8');
    define('DB_COLLATE', '');

    If I connect to the MYSQL database using mysql from the command line with these settings, all is well. This indicates that the username, password and host are all correct. Why then, will WordPress not connect?

    Any help most appreciated.

  2. sanypoo
    Posted 5 years ago #

    have you Rename the wp-config-sample.php file to wp-config.php.?

  3. vaujanolo
    Posted 5 years ago #

    Yes, the info above was from the config file.

    I am actually moving an existing WordPress install from my ISP to my own Mac OSX Server. I have got the MYSQL database running, I just can't get it to talk to WordPress.

  4. Have you used phpMyAdmin to make a database or made a database via terminal and Mysql?

  5. vaujanolo
    Posted 5 years ago #

    I used phpmyadmin.

    I managed to login to the database using the terminal to check the username and password.

    Any ideas?

  6. Sure the mysql username is not root, which is typical in OS X? Check and check again.


  7. vaujanolo
    Posted 5 years ago #

    Yes, I can login via the terminal by doing:

    mysql -h localhost -u mynews -p

    and putting the password in. This shows my username and password are correct.

    Thanks for your help though. Any other suggestions?

  8. bragggf
    Posted 5 years ago #

    I am having the same issue. I am using a remote MySQL database running on a solaris box that is already supporting other wordpress databases. However on my local install I am unable to establish/maintain a php connection. This is not a user/password/database/host permissions issue. Something amiss between php and mysql:

    running a php-mysql connection test returns the following:

    Lost connection to MySQL server at 'reading initial communication packet', system error: 146

    Believe the remote MySQL version is 5.1.46

  9. luisbonie
    Posted 4 years ago #

    If you have changed your database password you need to also change it in your wp-config file...

    /** MySQL database password */
    define('DB_PASSWORD', 'Change It Here');

    I hope this is your solution :]

  10. shinshugita
    Posted 4 years ago #

    set host to instead of localhost.

Topic Closed

This topic has been closed to new replies.

About this Topic