Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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

like image 884
Bar Akiva Avatar asked Jan 01 '26 02:01

Bar Akiva


2 Answers

Change db_host from localhost to 127.0.0.1:8889

like image 89
Joel Glovacki Avatar answered Jan 04 '26 23:01

Joel Glovacki


I think the error you are facing because of incorrect database configuration for instance DB_USER & DB_PASSWORD. There is no need to change/rename/copy/pase the file name i.e- wp-config-sample.php

You need to carefully configure the DB_NAME & DB_PASSWORD otherwise you will face such errors during db connectivity. I was facing the same issue but when i set authentication phpMyAdmin to no passowrd the installation goes continue. In this case you need to set no password in phpMyAdmin. Than start configuation properly:

Open the configuration file with notepad and carefully change the database details, than save with existing name. Furthermore when you connect to database, the config file will automatically create in the web directory. Now change according to your need and requirements.

define('DB_NAME', 'wp_demo');

/** MySQL database default username */
define('DB_USER', 'root');

/** MySQL database default password you can leave it blank.
define('DB_PASSWORD', '');

/** 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', '');
like image 42
R.p. Singh Avatar answered Jan 04 '26 21:01

R.p. Singh



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!