Installation Issue WordPress locally – The file ‘wp-config.php’ already exists

I have the issue with installation WordPress locally on my computer, XAMPP environment.

In PHPMyAdmin I created an empty database, later I will import database that I downloaded from the live server, and other files and folders also.

Apache and MySql modules are started correctly and when I type localhost in my Chrome browser, I can not install WordPress in two ways, first when I try to install without manually created wp-config.php file – Error establishing a database connection. Second way, I create wp-config.php file with same credentials and database name, but I got this error –

The file ‘wp-config.php’ already exists. If you need to reset any of
the configuration items in this file, please delete it first. You may
try installing now.

I tried to clear cache and cookies from my browser, but the problem is still here.

1 Answer
1

Normaly on servers you can install WP with WP installation proccess and you will have auto generated wp-config.php file. On some servers you need to create wp-config.php manualy.

Here is how to prepare WordPress installation:

  1. In MySQL you need to create empty database
  2. Place in root of your server WP ZIP file
  3. Extract ZIP file with some zip manager
  4. Move WP installation files and folders from wordpress in root
  5. In browser go to your WP http://127.0.0.1/your-root/

Now you starting installation.

If you see standard WordPress installation page with initial steps, you can isntall WP selecting language and inserting database name, username, pasword and localhost in host field.

If you see error like you mention, you need to create wp-config.php inside root folder, copy whole PHP code from wp-config-sample.php 1:1 and change pharams like this:

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

Note that DB_CHARSET need to be same like your encoding in database what you create before. Also DB_COLLATE leave empty.

After that your WP will just ask you for database update and all will work fine.

I believe this may be caused by an old version of WordPress that is being installed by Softaculous.

Also, take a look for this line at the bottom of your wp-config.php file, remove it and try again.

require_once(ABSPATH . 'wp-admin/setup-config.php');

Default XAMPP host is localhost, password is not setup (empty) and username is root.

Also I need to mention, sometimes in XAMPP you can have conflict with Skype and you must disable inside Skype port 80 and 443 in Tools->Options->Advanced->Connection and after that restart Skype.

I hope this can help you.

Leave a Comment