0

When uploading my site to the remote Bluehost server (using FileZilla), I mistakenly changed the local (rather than remote) wp-config.php file and can no longer log into my localhost /wp-admin.

I tried to revert the local WP-config file back to link it to my site's local database, but I am now prompted to go through a new installation of WordPress (language settings, etc.).

How do I go about fixing my local wp-config.php file so I can log into my localhost/site/wp-admin panel?

0

Once I wrote a tutorial on what to do when you delete the wp-config.php file, the article was in Bengali (bn_BD):

ওয়ার্ডপ্রেসের wp-config.php মুছে ফেললে করণীয় (Web Archive)

You can use Google Translate to get the gist of the article.

Summary

  1. Copy the wp-config-sample.php, paste and rename the file into wp-config.php
  2. Find out the database table that is responsible for the project, and get the MySQL settings as well. Now fill the database credentials:
define( 'DB_NAME', 'database_name_here' ); // DATABASE
define( 'DB_USER', 'username_here' ); // MySQL username
define( 'DB_PASSWORD', 'password_here' ); // MySQL password (empty string for no password)
define( 'DB_HOST', 'localhost' );
  1. For the Unique Keys and Salts, get to WordPress Secret Key (Salt) Generator – WordPress API and copy all the texts, replace the following code with copied texts:
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' );
  1. For the table prefix, get to the database using a DB application like PHPMyAdmin and see the table prefixes there. Typically they start with wp_, if you notice any changes there, you can change the following line with the one that you have in your table names:
$table_prefix = 'wp_';

And that's all. It is that simple.

If you see 404 in some pages you can get to the /wp-admin » Settings » Permalinks, and hit the Save Changes button to refresh the .htaccess Rewrite rules.

Your situation

As you said:

I tried to revert the local WP-config file back to link it to my site's local database, but I am now prompted to go through a new installation of Wordpress (language settings, etc.).

This probably because you put the wrong database name in the DB_NAME definition (define( 'DB_NAME', 'database_name_here' );), what needs to the exact same database that was responsible for the local website. If the database name was correct, then, your database might be truncated, etc. If so, you will need to recover the database from your backup (or as you have a remote version, you can grab the data from there too).

| improve this answer | |

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.