wp-config.php Missing / Not Found

First of all, if you have a brand new WordPress website and can’t find wp-config.php, don’t panic – it’s nothing wrong or unusual or unexpected. When you download WordPress from wordpress.org/download/ and upload the files to your server, the wp-config.php file is not included and must be added manually. This is different from how it used to be a few years ago, when wp-config.php was included, but you had to change it anyway.

If the wp-config.php file is missing, there are three four ways to get it – see below (options 1 or 2 are the best for most people).

1) Let WordPress Create It Automatically

This one requires the least computer skills and is the fastest.

When wp-config.php is missing and you enter your website’s address into the browser, it usually displays a page which offers you to create it automatically. It starts with

“Welcome to WordPress. Before getting started, we need some information on the database. You will need to know the following items before proceeding.”

which is followed by a list of 5 items and some more text. The url of this page is usually

“www.yoursite.com/wp-admin/setup-config.php” (or similar).

The whole page looks like this:

wp-config.php automatic creation

There is nothing you need to do on this page. Just click the “Let’s go!” button in the bottom and you will see another page:

wp-config.php automatic creation

On this page you need to enter your WordPress database name, username and password. They are NOT the username and password you use to log into your webhosting account; they are set specifically for your database(s). You can set or change your database name, username and password in the “MySQL Databases” section of your cPanel – the link to enter that section looks like this:

cPanel MySQL Databases link

If you have problems finding or creating your database, your web hosting provider will be able to help.

Database Host is usually localhost, so you can keep that one. If it’s not localhost, again your hosting provider will tell you what to enter there.

The final field, Table Prefix, is a short string of text which will be attached to each table’s name to identify this WordPress instance. If you only have one website in the database, you can keep it as it is “wp_”. If you have multiple websites in one database, they will need to have different table prefixes.

Finally, click “Sumbit” and your wp-config.php will be created. You will then be able to go through the WordPress admin account setup and choose your WordPress admin username, email and password (which are again different from your web hosting account login details and also different from the database username and password above).

That’s it. You can now log into WordPress admin and start adding content.

2) Create wp-config.php from wp-config-sample.php

The method above is quick and easy and it is the best for people with only very basic computer skills. It has some limitations, particularly if you also want your wp-config to set other options besides the core essentials.

The second method is not particularly demanding either. The only tech skills required are being able to locate a file on your server, copy the file, rename the file, edit the file in a basic text editor and copy it back to the server. It is a php file, but it’s quite short and does not involve any heavy programming.

Although the new WordPress files package does not include a wp-config.php, it does include a file named wp-config-sample.php and, as the name suggests, it is a file which can be modified to create a working wp-config.php.

wp-config-sample.php is located in the root directory of your WordPress, the same location where wp-config.php should eventually be (see wp-config.php location).

To create your wp-config.php from wp-config-sample.php, you can follow our step-by-step guide here.

3) Create It from wp-config.php on Your Other Website

If you have other websites, it may be easier to create wp-config.php by adjusting an existing wp-config which you have on some other website of yours. It works the same as creating it from wp-config-sample.php, but has two advantages:

  • You may need to change fewer settings. Theoretically you may only need to change one row of code – either the database name (if your new website has its own database) or the table prefix (if your new website is in the same database as the existing one). However, for security reasons it may be better to use different usernames and passwords for different websites and in that case you will also need to change these.
  • If you are using some advanced settings (for example you have post revisions turned off) and you want the same for all your websites, you don’t need to add or change them manually again.

4) Write It from Scratch

There is actually a fourth option for those who know some php and are familiar with a little more of WordPress, but obviously this option will take more time and is more prone to errors and omissions compared to the options above. You may still want to try it as a php/WordPress exercise.