Close Menu
Infoceptor
  • Business
  • Finance
  • Technology
  • Health
  • Life
  • More
    • Auto
    • Food
    • Health
    • Home
    • Space
    • Travel

Subscribe to Updates

Get the latest creative news from FooBar about art, design and business.

What's Hot
Flywheel Logo

Flywheel review in 2023

June 8, 2023
Travel restrictions in Canada are different depending on where you're traveling from and to. Here's what you need to know before you go.

Canada: Traveling restrictions and what you need to know before you go

May 19, 2024
If you are planning a trip to Spain, there are some travel restrictions that must be taken into consideration.

Spain: Traveling restrictions and what you need to know before you go

May 19, 2024
Facebook X (Twitter) Instagram
Infoceptor
  • Business
    This guide will show you how to determine the value of your business using different business valuation methods.

    How to value you business – The ultimate guide for 2023

    May 9, 2024
    Have you ever thought of starting your own laundry service? Find out how with this easy guide.

    How to start a laundry service company in 2023

    May 5, 2024
    Learn about the best online payment solutions available to you. Check out what’s available, learn their pros and cons, and choose the one that best fits your needs.

    The 15 best online payment solutions in 2023

    April 27, 2024
    Learn how to create powerful backlinks for your website and increase your site's search engine ranking.

    How to build backlinks to your website

    April 25, 2024
    In this beginner's guide, we will show you the steps involved in creating a mobile app.

    Beginner’s guide on how to develop a mobile app

    April 24, 2024
  • Finance
    Learn how to build wealth and financial security. This article will share steps you can take to build a reliable cash reserve that will grow over time.

    Do you want to build wealth? Here are some ways to grow your money

    May 18, 2024
    Want to know your tax bracket? Check out our article for an overview of the different brackets and what you can expect to pay in 2022.

    Understanding IRS tax brackets – here’s what you’ll pay in 2023

    May 14, 2024
    This article will cover the best electric vehicle battery stocks to buy and invest in.

    The 10 best EV battery stocks to buy in 2023

    May 9, 2024
    The 10 most active penny stocks to watch this year is a list of the most active penny stocks ranked by total volume.

    The 10 most active penny stocks to watch in 2023

    May 8, 2024
    These electric car stocks are making a lot of money and you should consider adding them to your portfolio.

    The best electric car stocks to buy in 2023

    May 8, 2024
  • Technology
    Flywheel Logo

    Flywheel review in 2023

    June 8, 2023
    This article provides a list of the top iPhone models available today. Each model is reviewed based on features, specifications, performance, design and price point.

    Top iPhone models we’ve tested and you should get

    May 17, 2024
    Find out everything you need to know about the Apple Airpods Pro, including their price, features and if they're worth buying.

    Are Apple AirPods Pro a great choice in 2023?

    May 17, 2024
    To help you find the best responsive WordPress themes, we analyzed more than 100 themes and found those that are currently trending.

    The best responsive WordPress themes in 2023

    May 16, 2024
    These sympathy gifts make a great way to show you care while they also help your loved ones get through the tough times.

    The 15 best sympathy gifts that will show you care

    May 15, 2024
  • Health
  • Life
    These sympathy gifts make a great way to show you care while they also help your loved ones get through the tough times.

    The 15 best sympathy gifts that will show you care

    May 15, 2024
    Water bottles are a great way to stay hydrated. This article is dedicated to the most popular water bottles of the year!

    The best water bottles of 2023

    May 10, 2024
    Learn 30 weird and fun facts that will make you question everything.

    30 weird and fun facts that will make you question everything

    May 10, 2024
    Find out which cities in the US are the best for quality of life by checking out this article.

    20 best cities for quality of life in the USA

    May 7, 2024
    There are many ways to print your designs on t-shirts. Check out our list of the best printing services that offer top-notch quality at affordable prices.

    The 10 best T-shirt printing services of 2023

    May 6, 2024
  • More
    • Auto
    • Food
    • Health
    • Home
    • Space
    • Travel
Facebook X (Twitter) Instagram
Trending
  • Flywheel review in 2023
  • Canada: Traveling restrictions and what you need to know before you go
  • Spain: Traveling restrictions and what you need to know before you go
  • Do you want to build wealth? Here are some ways to grow your money
  • Our in-depth review of the Always Pan
  • Top iPhone models we’ve tested and you should get
  • Are Apple AirPods Pro a great choice in 2023?
  • The best shower heads of 2023
Infoceptor
Home»Technology»WordPress»How to edit the WordPress configuration file (wp-config.php)
WordPress

How to edit the WordPress configuration file (wp-config.php)

Matthew DrummondBy Matthew DrummondOctober 5, 20238 Mins Read
Facebook Twitter LinkedIn Reddit Telegram WhatsApp Pinterest Email
Share
Facebook Twitter LinkedIn

Sometimes, you’ll stumble upon a tutorial that asks you to edit the WordPress configuration file (wp-config.php), so here’s our article that helps explain how it works and how to edit it.

wp-config.php is part of the WordPress Core, and it’s automatically generated whenever you go through the setup of a new WordPress website. It stores various useful information that keeps your website up and running, for example:

  • Database connection information
  • Authentication keys
  • Database table prefix option
  • Debug mode

Default wp-config.php

Here’s how the entire default wp-config.php file looks like:

<?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://wordpress.org/support/article/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 documentation.
 *
 * @link https://wordpress.org/support/article/debugging-in-wordpress/
 */
define( 'WP_DEBUG', false );

/* That's all, stop editing! Happy publishing. */

/** Absolute path to the WordPress directory. */
if ( ! defined( 'ABSPATH' ) ) {
	define( 'ABSPATH', __DIR__ . '/' );
}

/** Sets up WordPress vars and included files. */
require_once ABSPATH . 'wp-settings.php';

As you can see, the majority of the settings are defined using PHP constants, in this format:

define( 'constant_name', 'value');

Edit wp-config.php

Each section is properly documented so you can understand what it’s used for.

To edit the wp-config.php file, you can either:

  • Download it via FTP; edit it on your computer, and then upload it back to your account
  • Edit it directly via the FileManager in your hosting control panel, cPanel control panel > Files section

Before moving to the next step, always make sure to create a backup of your WordPress database and folder.

Let’s explain what each part does!

MySQL Configuration

The first section is related to your website’s database configuration, and to fill this section, you will need your database name, username, and password.

// ** 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 keys

The wp-config.php file includes secret authentication security keys and salts, which are additional passwords that provide secure encryption. Together with cookies, they help verify the identity of logged-in site users and commenters. The authentication keys are almost impossible to break since they are long, random and complicated. Here’s how this section looks:

/**#@+
 * 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');
 
/**#@-*/

These are generated in the wp-config.php file by default when you install WordPress. However, if you suspect that your website security could be compromised, you can create new WordPress security keys here and paste them in the authentication section.

This action will log out all currently logged-in users on your site and they will be required to log in again.

WordPress database table prefix

WordPress automatically adds a wp_ prefix to all database tables created through it to differentiate them, and this setting can be changed in the wp-config.php file as well:

/**
 * 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_';

However, it’s not recommended to change this value after the installation as it’s not straightforward. You’ll need to rename all your database tables to match the new prefix, and update options and usermeta tables.

Some advanced users like to change this setting to make it difficult for hackers to execute common SQL injection attacks.

Debugging mode

WordPress hides errors and notices by default, and those don’t show on the website unless debugging mode is enabled. Here’s how the WordPress debug mode looks inside the wp-config.php file:

define('WP_DEBUG', false);

You can force WordPress to show errors and warnings that can help you in theme and plugin debugging by changing the value to True. However, if you are working on a live site, you should consider disabling the debug mode for website security reasons.

When the value is set to true, errors and warnings can be shown to anyone, which may give hackers sensitive information to find a vulnerability to exploit. The ‘false’ value is the default value and means that debug mode is disabled.

Absolute path settings

This section can be ignored as it’s already set up, and helps WordPress configure variables and included files via absolute path.

/* That's all, stop editing! Happy publishing. */  
  
/** Absolute path to the WordPress directory. */  
  
if ( ! defined( 'ABSPATH' ) ) {  
  
 define( 'ABSPATH', __DIR__ . '/' );  
  
}  
  
/** Sets up WordPress vars and included files. */  
  
require_onceABSPATH . 'wp-settings.php';

Advanced tips and tricks

You can also use some advanced wp-config.php settings to troubleshoot problems and fix some basic WordPress errors.

Upload directory

If you want to change your default upload directory for your media, you can do so by adding the following variable to the wp-config.php file:

define( 'UPLOADS', 'wp-content/media' );

Make sure to change wp-content/media to the desired directory name and location.

Disable automatic updates

Automatic updates are fantastic for security; however, in some cases – they can break websites as not all plugins and themes are updated for new WordPress versions immediately.

You can disable automatic updates by adding the following line to your wp-config.php file:

define( 'WP_AUTO_UPDATE_CORE', false );

Make sure to keep your WordPress core and all plugins and themes updated to avoid potential security issues.

Change your website URL

If you want to move your website to the new domain, you need to configure WordPress for this as well. You can change your home and site URLs from your WordPress dashboard > Settings > General page, but in case you’re not able to access it, you can also do this via wp-config.php file by adding the following lines:

define('WP_HOME','http://yourdomain.com');
define('WP_SITEURL','http://yourdomain.com');

Make sure to adjust yourdomain.com to your new domain name.

Adjust MySQL port and sockets

If you’re on one of our managed plans, you’ll never have to touch it, but if needed, you can adjust the database hostname and port like this via wp-config.php file:

define( 'DB_HOST', 'localhost:XXXX' );

(Replace localhost and XXXX with the correct database server hostname and port)

Limit post revisions

WordPress keeps saves of your post and page edits in its revision system automatically, and if you have a big website – this could result in a massive amount of data. This makes it harder to operate and back up your website. You can limit the number of revisions WordPress keeps for each post via this line of code:

define( 'WP_POST_REVISIONS', 4 );

Replace the number 4 with the number of revisions you want to keep, and WordPress will automatically dismiss the older changes.

People also viewed:

How to edit the author in WordPress How to edit the ‘Powered by WordPress’ text and link in the footer area How to reorder posts in WordPress and WooCommerce How to make your WordPress site more secure The best ad creation plugins to monetize your WordPress website
configuration edit WordPress wp-config wp-config.php
Share. Facebook Twitter LinkedIn Reddit Telegram WhatsApp Pinterest Email
Previous ArticleBest WordPress plugins for metrics and analytics to measure traffic
Next Article How to create a survey in WordPress
Matthew Drummond

Matthew is a Infoceptor Technology writer. Having worked as a systems administrator for over 15 years gives him unique insight into the inner works of technology. Ultimately his passion for writing brought him to share his technical expertise with the world.

Related Stories

How to edit the author in WordPress

February 14, 2024

How to reorder posts in WordPress and WooCommerce

February 14, 2024

How to make your WordPress site more secure

February 13, 2024

How to edit the ‘Powered by WordPress’ text and link in the footer area

March 31, 2022

Comments are closed.

Connect
  • Facebook
  • Twitter
  • Pinterest
  • Instagram
  • YouTube
  • LinkedIn
  • Reddit
  • TikTok
Don't Miss
Flywheel Logo Reviews

Flywheel review in 2023

By Matthew Drummond

Flywheel is a fast-growing web host that offers high-performance WordPress hosting for agencies, designers, and developers.

Travel restrictions in Canada are different depending on where you're traveling from and to. Here's what you need to know before you go.

Canada: Traveling restrictions and what you need to know before you go

May 19, 2024
If you are planning a trip to Spain, there are some travel restrictions that must be taken into consideration.

Spain: Traveling restrictions and what you need to know before you go

May 19, 2024
Learn how to build wealth and financial security. This article will share steps you can take to build a reliable cash reserve that will grow over time.

Do you want to build wealth? Here are some ways to grow your money

May 18, 2024
  • Auto
    • Auto Reviews
    • Electric
    • Insurance
  • Business
    • Company
    • Government
  • Entertainment
    • Movies
    • Music
  • Finance
    • Credit Cards
    • Crypto
    • Market
    • Personal Finance
  • Food
    • Coffee
    • Drinks
    • Holidays
  • Health
  • Beauty
  • Fitness
  • Food
  • Medical
  • Home
  • Backyard
  • Bathroom
  • Bedroom
  • Cleaning
  • Furniture
  • Home Office
  • Kitchen
  • Life
  • Astrology
  • Family
  • Fashion
  • Outdoors
  • Personal
  • Pets
  • Apple
  • Audio
  • Domain Names
  • Gaming
  • Google
  • Power
  • Reviews
  • Samsung
  • Destinations
  • Gear
  • Services
  • Space
  • Tourism
  • Technology
  • Tutorials
  • Web Hosting
  • WiFi
  • WordPress
  • Travel
  • Shopping
  • Sports
  • Work
  • Stocks
  • Television
  • Web Hosting
Facebook X (Twitter) Instagram Pinterest YouTube LinkedIn Reddit TikTok
© 2025 Infoceptor

Type above and press Enter to search. Press Esc to cancel.