0

I was working on my MacOS System with everything well configured and working. Now I try to migrate all of my work to Windows using the same software as in MacOS MAMP to run Wordpress on localhost. So I set up MAMP on my Windows System and copied all files from GitHub to my workstation on Windows.

The problem is, when I try to access to my Wordpress Project on my localhost, I get the error:

"Error establishing a database connection"

enter image description here

I can not even have wp-config.php file and I can't get it.

Searching for similar problems around here I have this link, but is not the same solutions.

1

Create a new file names wp-config.php and paste all the code than enter your db credentials it will solve your wp-config issue.

<?php
/**
 * The base configurations of the WordPress.
 *
 * This file has the following configurations: MySQL settings, Table Prefix,
 * Secret Keys, WordPress Language, and ABSPATH. You can find more information
 * by visiting {@link http://codex.wordpress.org/Editing_wp-config.php Editing
 * wp-config.php} Codex page. You can get the MySQL settings from your web host.
 *
 * This file is used by the wp-config.php creation script during the
 * installation. You don't have to use the web site, you can just copy this file
 * to "wp-config.php" and fill in the values.
 *
 * @package WordPress
 */

// ** MySQL settings - You can get this info from your web host ** //
/** The name of the database for WordPress */
define('DB_NAME', 'database_name_here');

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

/** MySQL database password */
define('DB_PASSWORD', 'password_here');

/** 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', '');

/**#@+
 * Authentication Unique Keys and Salts.
 *
 * Change these to different unique phrases!
 * You can generate these using the {@link https://api.wordpress.org/secret-key/1.1/salt/ WordPress.org secret-key service}
 * You can change these at any point in time to invalidate all existing cookies. This will force all users to have to log in again.
 *
 * @since 2.6.0
 */
define('AUTH_KEY',         'put your unique phrase here');
define('SECURE_AUTH_KEY',  'put your unique phrase here');
define('LOGGED_IN_KEY',    'put your unique phrase here');
define('NONCE_KEY',        'put your unique phrase here');
define('AUTH_SALT',        'put your unique phrase here');
define('SECURE_AUTH_SALT', 'put your unique phrase here');
define('LOGGED_IN_SALT',   'put your unique phrase here');
define('NONCE_SALT',       'put your unique phrase here');

/**#@-*/

/**
 * WordPress Database Table prefix.
 *
 * You can have multiple installations in one database if you give each a unique
 * prefix. Only numbers, letters, and underscores please!
 */
$table_prefix  = 'wp_';

/**
 * For developers: WordPress debugging mode.
 *
 * Change this to true to enable the display of notices during development.
 * It is strongly recommended that plugin and theme developers use WP_DEBUG
 * in their development environments.
 */
define('WP_DEBUG', false);

/* That's all, stop editing! Happy blogging. */

/** Absolute path to the WordPress directory. */
if ( !defined('ABSPATH') )
    define('ABSPATH', dirname(__FILE__) . '/');

/** Sets up WordPress vars and included files. */
require_once(ABSPATH . 'wp-settings.php');
  • 1
    Note: With every downloaded - official source I assume - version of WordPress there comes the file wp-config-sample.php for this very reason. Filling in credentials and renaming it to wp-config.php is - under normal/standard circumstances - enough. – Nicolai Aug 4 '15 at 11:54
  • 1
    may i know what version of wordpress you have ?? – Satish Mehta Aug 4 '15 at 12:01
  • 1
    can you share the database so that i can address the error because i sent you the 4.2.3 config code – Satish Mehta Aug 4 '15 at 12:17
  • 1
    do one thing reach your database and find these : define('AUTH_KEY', 'put your unique phrase here'); define('SECURE_AUTH_KEY', 'put your unique phrase here'); define('LOGGED_IN_KEY', 'put your unique phrase here'); define('NONCE_KEY', 'put your unique phrase here'); define('AUTH_SALT', 'put your unique phrase here'); define('SECURE_AUTH_SALT', 'put your unique phrase here'); define('LOGGED_IN_SALT', 'put your unique phrase here'); define('NONCE_SALT', 'put your unique phrase here'); and fill them in your wp-config file i wish this will definitely work – Satish Mehta Aug 4 '15 at 12:19
  • 1
    do you have remaining contents except wp-config i mean like all other files plus database ?? – Satish Mehta Aug 4 '15 at 12:35
1

You need to create wp-config.php file. This new file is copy of wp-config-sample.php find it in root directory.

After creating this copy name it wp-config.php and set up database setting into it. Also give access permission to it.

Let me know if above wording is not used to for you.

  • 1
    You are getting the same error on both the front-end of the site, and the back-end of the site (wp-admin). – AddWeb Solution Pvt Ltd Aug 4 '15 at 12:45
  • 1
    If the error message is the same on both pages "Error establishing a database connection", then proceed onto the next step. If you are getting a different error on the wp-admin for instance something like "One or more database tables are unavailable. The database may need to be repaired", then you need to repair your database. – AddWeb Solution Pvt Ltd Aug 4 '15 at 12:59
  • 1
    You can do this by adding the following line in your wp-config.php file – AddWeb Solution Pvt Ltd Aug 4 '15 at 12:59
  • 1
    define('WP_ALLOW_REPAIR', true); – AddWeb Solution Pvt Ltd Aug 4 '15 at 13:00
  • 1
    Once you have done that, you can see the settings by visiting this page: yoursite.com/wp-admin/maint/repair.php – AddWeb Solution Pvt Ltd Aug 4 '15 at 13:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.