Docs / Using WordPress / Editing your WordPress wp-config File

4. Editing your WordPress wp-config File

Written by Patrick Cohen | Last updated: February 6, 2024

In this document, we will look at how to edit your wp-config file. This is the file that provides WordPress with important information such as database login information, secure tokens, and WP_DEBUG.

4.1 Editing wp-config

Copy chapter anchor to clipboard

Now that you have set up your MySQL database and username you need to decide how you want to create your wp-config.php file for your WordPress installation.

The wp-config.php is the file contained in the root of your WordPress file directory which contains the login information for WordPress to connect to your MySQL database(s) as well as table prefix, secret keys, WordPress language and ABSPATH.

You can either:

  1. Create and edit the wp-config.php file yourself,
  2. Or skip this step and let WordPress try to do this itself when you run the installation script using the web interface. If you skip this step go to Installing WordPress using FTP.

The safest way is to manually create your wp-config.php file following the instructions below as the installation script using the web interface doesn’t work for all server setups.

Downloading WordPress

1. Download the zip version of WordPress from wordpress.org
2. Unzip the downloaded file to a folder on your hard drive.

Renaming the wp-config-sample.php file to wp-config.php

1. Locate the wp-config-sample.php file within the wordpress folder inside the wordpress folder you unzipped.
2. Right click on wp-config-sample.php file, view Properties, and rename to wp-config.php

Rename wp-config-sample file

Edit your wp-config.php

You now need to edit your wp-config.php file for your installation.

You should do this using a Text Editor program such as EditPlus or Notepad++. Both are text editor, HTML editor and programmer’s editor for Windows. While you could edit in regular NotePad, these editors offer many powerful features that make them better suited for editing PHP.

For Mac Users try:

  1. Smultron – Text Edit software for purchase designed for MacOS Sierra 10.12 or later.
  2. Textmate – Text Edit software for purchase designed for Macs – very good and better suited to text editing

Please note:

  • You must use a text editor program which edits files in plain text format as non-text based word processing program such as Microsoft Word can cause major problems to code when used to edit PHP files.

Use your editor as follows to edit your wp-config.php file:

1. Download and install the editor you prefer.
2. Locate your wp-config.php file on your hard drive.
3. Right mouse click on your wp-config.php file and select to open your wp-config.php file for editing using that editor.

Edit file with Notepad++

4. Change the wp-config.php file for your installation by adding:

  • Your database name
  • Your username used to access the database
  • Your password used to access your Database
  • The host name of your database server — the host name is usually localhost but if concerned you can confirm by contacting or searching your hosting company’s online documentation.

These are all the details that you set up when you created your MySQL database and user.

edit wp-config database settings and user details

5. Go to the WordPress secret key generator to grab unique authentication keys and salts. Then replace the default empty ones in your wp-config.php file.

  • These values can be anything you want them to be — it is just easier to auto-generate them using the key generator
  • These values help WordPress operate securely

Replace default security salts in wp-config.php

6. Finally, save all changes to your wp-config.php file and upload the file to the root of your WordPress install (the same directory where the wp-config-sample file was located).

Example wp-config.php File

This is an example of what your wp-config.php file will look like. Don’t forget to fill in all values with your own.

If you still have questions or need assistance after reading this document, please don’t hesitate to contact our support superheroes using the available options under the Support tab in your Hub or via the Support tab in your WPMU DEV Dashboard.

Link to getting support