• I have installed wordpress on my machine (localhost, macOSX) and everything worked for a few months with no problem.

    yesterday I got the message

    “Error establishing a database connection”

    Google it and try to fix it:

    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

    however I can connect to the database (Server version: 5.5.0-m2 MySQL Community Server (GPL)) with

    mysql -h localhost -u wordpress -p

    I can see the database with its tables…

    and If I open wp-config.php (which I haven’t modify) it is:

    // ** MySQL settings - You can get this info from your web host ** //
    /** The name of the database for WordPress */
    define('DB_NAME', 'drybook');
    
    /** MySQL database username */
    define('DB_USER', 'wordpress');
    
    /** MySQL database password */
    define('DB_PASSWORD', 'wp_pwd');
    
    /** MySQL hostname */
    define('DB_HOST', 'localhost');
    
    /** Database Charset to use in creating database tables. */
    define('DB_CHARSET', 'utf8');
    
    /** The Database Collate type. Don't change this if in doubt. */
    define('DB_COLLATE', '');

    So, to me the database is up and running and the config file is ok…

Viewing 2 replies - 1 through 2 (of 2 total)
  • this happens to me occasionally
    you need to log in to phpmyadmin and run a repair on wp_options table

    Thread Starter stefano6791

    (@stefano6791)

    thank you. Also phpMyAdmin gave an error. Googling for that error I could find a solution. Turned out it was the operative system: Mac OSX

    “Open a terminal, type in “ls -al /etc/php.ini*”
    If a php.ini does not exist copy over the default php.ini, “sudo cp /etc/php.ini.default /etc/php.ini”
    Now edit the php.ini, “sudo nano /etc/php.ini” (or use your prefered editor)
    Find “mysql.default_socket” (you can search using [Ctrl]+[w] in nano)
    Enter “/tmp/mysql.sock” after the equals sign.
    Don’t forget to save the file ([Ctrl]+[o] [Enter] in nano)
    Now restart Apache, “sudo apachectl graceful”

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Error establishing a database connection’ is closed to new replies.