Error "Sorry, I need a wp-config-sample.php file to work from. Please re-upload this file from your WordPress installation."

17,043

Change db_host from localhost to 127.0.0.1:8889

Share:
17,043
Bar Akiva
Author by

Bar Akiva

Updated on June 28, 2022

Comments

  • Bar Akiva
    Bar Akiva almost 2 years

    I have been getting this error while installing Wordpress locally:

    "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."

    I searched the web for a solution. Most people said to check if MySql server is online (MAMP says it is) or change the wp-config-sample.php file.

    // ** MySQL settings - You can get this info from your web host ** //
    /** The name of the database for WordPress */
    define('DB_NAME', 'wp_demo');
    
    /** MySQL database username */
    define('DB_USER', 'root');
    
    /** MySQL database password */
    define('DB_PASSWORD', 'root');
    
    /** 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', '');
    

    I have done it and still to no avail. The last step was changing the "wp-config-sample.php" filename to "wp-config.php" which netted me this error:

    "Sorry, I need a wp-config-sample.php file to work from. Please re-upload this file from your WordPress installation."

    I am using Win 7, MAMP 3.3.1 PHP 7.1.5. Localhost is on port 8888. MySql is port 8889