When you spin off a new WordPress website, wp-config.php file is one of the most important files you’ll be editing.
You might already have worked with it while changing the. database settings if you’ve installed the WordPress by yourself.
Keep in mind that when you download the WordPress, you won’t see the wp-config.php file included in that download but it’ll be generated while you install the WordPress because it needs database configurations inputs from you.
You might have noticed, while using local WordPress installer, that they ask for the database and other info first before starting the WordPress installation.
The wp-config.php file is located at the root level of your WordPress folder structure.
The wp-config.php file has all the basic settings related to your WordPress website for e.g. database connection, server configurations, PHP testing info etc.
There is a way to create wp-config.php file if you accidentally delete it. WordPress included wp-config-sample.php at the root level of your WordPress install directory. You can copy that file and rename it to wp-config.php.
Now keep in mind that…
- You must name the file wp-config.php and nothing else otherwise WordPress won’t recognize it.
- The order of the content in wp-config.php file is very specific. You might break your site if you change the order of the contents the way it’s supposed to be. Make sure you know the basic before you play with it.
How to update database configurations in WordPress?
To update the database configurations you need to change the contents inside the wp-config.php file.
When you’re setting up your website on a new server, you need to change your database configurations. You should be able to get that from your server providers.
To change the database configurations, you need to have these information handy.
- Database Name
- Database Username
- Database Password
- Database Host
- In some cases you might need a port number, Unix socket file path or pipe.
An example of a default wp-config-sample.php
/** 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' );
basics file wp-admin wp-config