Download our exclusive 10-Point WP Hardening Checklist:
Edit wp-config.php To Add WordPress Database Credentials | WP Learning Lab
In another video (here: I showed you how to create a MySQL database for your WordPress site. In this video I’m going to show you how to edit wp-config.php file to include the database credentials.
Although many people will be intimidated by it, editing wp-config.php is quite easy once you know the steps. So I encourage you try.
The first thing you must do to edit config file is log into the root directory of your WordPress site. You can do this via FTP or the file manager in your hosting account, whatever you’re most comfortable with.
Find a file called wp-config-sample.php and open it for editing wp-config.php. Scroll down to where it says MySQL Settings. Just below that you will see three important entries:
1. define(‘DB_NAME’, ‘database_name_here’);
2. define(‘DB_USER’, ‘username_here’);
3. define(‘DB_PASSWORD’, ‘password_here’);
Carefully replace database_name_here with the MySQL database name you created. Make sure that the single quotes stay, you only want to replace the text database_name_here.
Replace username_here with the username you created and replace password_here with the password you created.
That’s all you need to install WordPress. You can save the file and exit or you can do a couple more tweaks that will make your site more secure.
If you want to exit now, simply save the file and close the text editor. Then make sure you change the file name from wp-config-sample.php to wp-config.php.
If you want to make some security tweaks then keep reading.
Scroll down in the wp config file to where it says Authentication Unique Keys and Salts. Keys and salts are unique characters that WordPress uses to make usernames and passwords extra hard for hackers to guess.
Go to the URL that is the instructions for the keys and salts ( Refresh the page that loads a few times and then copy and paste the block of code that appears on that page. Paste that code block into the wp-config.php file replacing the demo code that exists. And you’re done with the unique keys and salts.
After that you can scroll down to where it says WordPress Database Table Prefix. By default the database prefix is wp_ and every hacker knows that. Every hacker also knows that 99% of webmasters don’t change the prefix. Hackers can take advantage of this information to gain access to your database. This is easily avoided.
Simply change the database table prefix to something random. You can only use letters and numbers and the underscore needs to be kept at the end of the prefix. For example, instead of wp_ you could make the prefix be tomfoolery_. The latter is much more difficult for a hacker to guess.
That’s it for basic wp-config.php security. You can now save the file, exit and rename it to wp-config.php.
I hope this information helps you! If you have any questions leave a comment below or ping me @WPLearningLab on Twitter.
All videos in the WP Learning Lab WordPress Installation Series:
1. WordPress Installation Introduction
2. Buying A Domain Name For Your Website (From GoDaddy) – Tips & Tricks of the Pros
3. WordPress Hosting: Buying A (BlueHost) Hosting Account for Your Website
4. Setting Name Servers In Your GoDaddy Domain Registrar Account
5. Create Add On Domains via cPanel
6. Downloading and Uploading WordPress.org (Self Hosted WordPress) Files
7. Create a MySQL Database for your WordPress Site via cPanel
8. Edit wp-config.php To Add WordPress Database Credentials
9. WordPress Installation Form & Logging In For The First Time
10. WordPress One Click Install
11. Create A Custom Email Address For Your Website Via cPanel
12. Forward Your Custom Email Address via cPanel
13. WordPress Installation Series Conclusion & Next Steps
If you want more excellent WordPress information check out our website where we post WordPress tutorials daily.
Connect with us:
WP Learning Lab Channel: