Blog

Editing your WordPress wp-config File

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.

Editing wp-config

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

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 Atom. Atom is a text editor, HTML editor and programmer’s editor for Mac and Windows. While you could edit in NotePad, Atom offers many powerful features that make it better suited for editing PHP.

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.

You use EditPlus3 as follows to edit your wp-config.php file:

1. Download and install a text editor such as Atom.
2. Locate your wp-config.php file on your hard drive.
3. Right mouse click on your wp-config.php file and select Atom to open your wp-config.php file for editing.

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.

// ** MySQL settings - You can get this info from your web host ** //
/** 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');
/** Database Charset to use in creating database tables. */
define('DB_CHARSET', 'utf8');
/** The Database Collate type. Don't change this if in doubt. */
define('DB_COLLATE', '');

5. Go to the WordPress secret key generator to grab authentication unique keys and salts then add them to 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
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');

This is what it would look like after pasting in the auto-generated keys from WordPress.

define('AUTH_KEY',         '7XT3p_x-G]@i(GJYFlK`@}-(EPdshHg<:brrz1`$1^vUS~XTIW |3=(xXv)iVmRE');
define('SECURE_AUTH_KEY',  'aw,^@5Q$W-_dqky3B!V*J0Cv)vc%(8]aO}JpDmxGSp!p=`r:jpkhkW(5mb*;bC{&');
define('LOGGED_IN_KEY',    '{O<Y*-Ci3+V=);{%1/w;eOW{-B9jS`*U0*NYfshS|J{:g$i*q>CB_;Kk-_~mk|?f');
define('NONCE_KEY',        '!ofo=&78%eb1AEfA)]1N1YqE^`u>4_.44wX-;c2NZF;=CA|vM%:4cd:FMle%[Hc9');
define('AUTH_SALT',        '94Y,,[|oH;^[S1!7v+K*bod_,k!K}``yl(gAww>g+7C6:UdXV%V[rru%Y7jWjOnF');
define('SECURE_AUTH_SALT', '!~a<rqn},4i50u,Y5KNCF*~TSpS[lKr@R[~xm~?lG-;$@=Ot->|X)BrX2P4Or|P;');
define('LOGGED_IN_SALT',   '*1+!-Bn&x-:mL:J94?rB+II+q,e,qQ]BjYxVYV(dM{gRrMX<x4ilm-V2t?yg f~N');
define('NONCE_SALT',       '&1`x=g9rM5mjSo5azC7qpR6 cg;2ZW?|bS{U;+9Y]]|qwpQA*X?ST7B27.. D`y|');

6. Finally, save all changes to your wp-config.php file and close your text editor.

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.

<?php
/**
 * The base configuration for WordPress
 *
 * The wp-config.php creation script uses this file during the
 * installation. You don't have to use the web site, you can
 * copy this file to "wp-config.php" and fill in the values.
 *
 * This file contains the following configurations:
 *
 * * MySQL settings
 * * Secret keys
 * * Database table prefix
 * * ABSPATH
 *
 * @link https://codex.wordpress.org/Editing_wp-config.php
 *
 * @package WordPress
 */
// ** MySQL settings - You can get this info from your web host ** //
/** 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');
/** Database Charset to use in creating database tables. */
define('DB_CHARSET', 'utf8');
/** The Database Collate type. Don't change this if in doubt. */
define('DB_COLLATE', '');
/**#@+
 * Authentication Unique Keys and Salts.
 *
 * Change these to different unique phrases!
 * You can generate these using the {@link https://api.wordpress.org/secret-key/1.1/salt/ WordPress.org secret-key service}
 * You can change these at any point in time to invalidate all existing cookies. This will force all users to have to log in again.
 *
 * @since 2.6.0
 */
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');
/**#@-*/
/**
 * WordPress Database Table prefix.
 *
 * You can have multiple installations in one database if you give each
 * a unique prefix. Only numbers, letters, and underscores please!
 */
$table_prefix  = 'wp_';
/**
 * For developers: WordPress debugging mode.
 *
 * Change this to true to enable the display of notices during development.
 * It is strongly recommended that plugin and theme developers use WP_DEBUG
 * in their development environments.
 *
 * For information on other constants that can be used for debugging,
 * visit the Codex.
 *
 * @link https://codex.wordpress.org/Debugging_in_WordPress
 */
define('WP_DEBUG', false);
/* That's all, stop editing! Happy blogging. */
/** Absolute path to the WordPress directory. */
if ( !defined('ABSPATH') )
	define('ABSPATH', dirname(__FILE__) . '/');
/** Sets up WordPress vars and included files. */
require_once(ABSPATH . 'wp-settings.php');

Originally published on WPMU DEV and written by Alex Stine | Last updated: January 4, 2017