How to Edit wp-config.php File in WordPress

Did you learn an educational that asks you to edit your wp-config record, and you haven’t any concept what it’s? Well we’ve were given you coated. In this text, we will be able to display you ways to correctly edit the wp-config.php record in WordPress.

What is wp-config.php File?

As the identify suggests, this can be a configuration record that is a part of all self-hosted WordPress websites.

Unlike different information, wp-config.php record does now not come built-in with WordPress moderately it’s generated in particular in your website all through the set up procedure.

WordPress shops your database knowledge in the wp-config.php record. Without this data your WordPress web site is not going to paintings, and you’ll get the ‘error organising database connection‘ error.

Apart from database knowledge, wp-config.php record additionally incorporates a number of different high-level settings. We will provide an explanation for them later in this text.

Since this record incorporates numerous delicate knowledge, it is strongly recommended that you just don’t mess with this record until you’ve got completely no different selection.

But because you’re studying this text, it way that you’ve to edit wp-config.php record. Below are the stairs to do it with out messing issues up.

Video Tutorial

If you don’t just like the video or want extra directions, then proceed studying.

Getting Started

First factor you want to do is to create a whole WordPress backup. The wp-config.php record is so the most important to a WordPress website {that a} tiny mistake will make your website inaccessible.

You will want an FTP consumer to attach to your web site. Windows customers can set up WinSCP or SmartFTP and Mac customers can take a look at Transmit or CyberDuck. An FTP consumer lets in you to switch information between a server and your laptop.

Connect to your web site the usage of the FTP consumer. You will want FTP login knowledge which you’ll be able to get out of your internet host. If you don’t know your FTP login knowledge, then you’ll be able to ask your internet host for reinforce.

The wp-config.php record is generally positioned in the foundation folder of your web site with different folders like /wp-content/.

wp-config file is located in the root directory of your WordPress site

Simply proper click on at the record after which make a selection obtain from the menu. Your FTP consumer will now obtain wp-config.php record to your laptop. You can open and edit it the usage of a simple textual content editor program like Notepad or Text Edit.

Understanding wp-config.php record

Before you get started, let’s check out the total code of the default wp-config.php record. You too can see a pattern of this record right here.


<?php
/**
 * The base configuration for WordPress
 *
 * The wp-config.php introduction script makes use of this record all through the
 * set up. You would not have to use the internet website, you'll be able to
 * replica this record to "wp-config.php" and fill in the values.
 *
 * This record incorporates the next configurations:
 *
 * * MySQL settings
 * * Secret keys
 * * Database desk prefix
 * * ABSPATH
 *
 * @hyperlink https://codex.wordpress.org/Editing_wp-config.php
 *
 * @package deal WordPress
 */

// ** MySQL settings - You can get this information out of your internet host ** //
/** The identify of the database for WordPress */
outline('DB_NAME', 'database_name_here');

/** MySQL database username */
outline('DB_USER', 'username_here');

/** MySQL database password */
outline('DB_PASSWORD', 'password_here');

/** MySQL hostname */
outline('DB_HOST', 'localhost');

/** Database Charset to use in growing database tables. */
outline('DB_CHARSET', 'utf8');

/** The Database Collate kind. Don't trade this if in doubt. */
outline('DB_COLLATE', '');

/**#@+
 * Authentication Unique Keys and Salts.
 *
 * Change those to other distinctive words!
 * You can generate those the usage of the {@hyperlink https://api.wordpress.org/secret-key/1.1/salt/ WordPress.org secret-key carrier}
 * You can trade those at any level in time to invalidate all current cookies. This will pressure all customers to have to log in once more.
 *
 * @since 2.6.0
 */
outline('AUTH_KEY',         'put your distinctive word right here');
outline('SECURE_AUTH_KEY',  'put your distinctive word right here');
outline('LOGGED_IN_KEY',    'put your distinctive word right here');
outline('NONCE_KEY',        'put your distinctive word right here');
outline('AUTH_SALT',        'put your distinctive word right here');
outline('SECURE_AUTH_SALT', 'put your distinctive word right here');
outline('LOGGED_IN_SALT',   'put your distinctive word right here');
outline('NONCE_SALT',       'put your distinctive word right here');

/**#@-*/

/**
 * WordPress Database Table prefix.
 *
 * You could have more than one installations in one database should you give each and every
 * a singular prefix. Only numbers, letters, and underscores please!
 */
$table_prefix  = 'wp_';

/**
 * For builders: WordPress debugging mode.
 *
 * Change this to true to permit the show of notices all through building.
 * It is strongly really useful that plugin and theme builders use WP_DEBUG
 * in their building environments.
 *
 * For knowledge on different constants that can be utilized for debugging,
 * discuss with the Codex.
 *
 * @hyperlink https://codex.wordpress.org/Debugging_in_WordPress
 */
outline('WP_DEBUG', false);

/* That's all, prevent enhancing! Happy running a blog. */

/** Absolute trail to the WordPress listing. */
if ( !outlined('ABSPATH') )
	outline('ABSPATH', dirname(__FILE__) . '/');

/** Sets up WordPress vars and integrated information. */
require_once(ABSPATH . 'wp-settings.php');

Each segment of wp-config.php record is easily documented in the record itself. Almost all settings listed here are outlined the usage of PHP Constants.


outline( 'constant_name' , 'worth'); 

Let’s take a better take a look at each and every segment in wp-config.php record.

MySQL Settings in wp-config.php File

Your WordPress database connection settings seem underneath ‘MySQL Settings’ segment of the wp-config.php record. You will want your MySQL host, database identify, database username and password to fill in this segment.


// ** MySQL settings - You can get this information out of your internet host ** //
/** The identify of the database for WordPress */
outline('DB_NAME', 'database_name_here');

/** MySQL database username */
outline('DB_USER', 'username_here');

/** MySQL database password */
outline('DB_PASSWORD', 'password_here');

/** MySQL hostname */
outline('DB_HOST', 'localhost');

/** Database Charset to use in growing database tables. */
outline('DB_CHARSET', 'utf8');

/** The Database Collate kind. Don't trade this if in doubt. */
outline('DB_COLLATE', '');

You can get your database knowledge out of your internet web hosting account’s cPanel underneath the segment categorized databases.

MySQL databases in cPanel

If you can’t to find your WordPress database or MySQL username and password, then you want to touch your internet host.

Authentication Keys and Salts

Authentication distinctive keys and salts are safety keys that assist make stronger safety of your WordPress website. These keys supply a robust encryption for consumer periods and cookies generated through WordPress. See our information on WordPress Security Keys for more info.


/**#@+
 * Authentication Unique Keys and Salts.
 *
 * Change those to other distinctive words!
 * You can generate those the usage of the {@hyperlink https://api.wordpress.org/secret-key/1.1/salt/ WordPress.org secret-key carrier}
 * You can trade those at any level in time to invalidate all current cookies. This will pressure all customers to have to log in once more.
 *
 * @since 2.6.0
 */
outline('AUTH_KEY',         'put your distinctive word right here');
outline('SECURE_AUTH_KEY',  'put your distinctive word right here');
outline('LOGGED_IN_KEY',    'put your distinctive word right here');
outline('NONCE_KEY',        'put your distinctive word right here');
outline('AUTH_SALT',        'put your distinctive word right here');
outline('SECURE_AUTH_SALT', 'put your distinctive word right here');
outline('LOGGED_IN_SALT',   'put your distinctive word right here');
outline('NONCE_SALT',       'put your distinctive word right here');

/**#@-*/

You can generate WordPress safety keys and paste them right here. This is especially helpful should you suspect your WordPress website will have been compromised. Changing safety keys will logout all these days logged in customers in your WordPress website forcing them to login once more.

WordPress Database Table Prefix

By default WordPress provides wp_ prefix to all of the tables created through WordPress. It is really useful that you just trade your WordPress database desk prefix to one thing random. This will make it tricky for hackers to wager your WordPress tables and can prevent from some not unusual SQL injection assaults.


/**
 * WordPress Database Table prefix.
 *
 * You could have more than one installations in one database should you give each and every
 * a singular prefix. Only numbers, letters, and underscores please!
 */
$table_prefix  = 'wp_';

Please notice that you can’t trade this worth for an current WordPress website. Follow the directions in our how to trade the WordPress database prefix article to trade those settings on an current WordPress website.

WordPress Debugging Mode

This surroundings is especially helpful for customers making an attempt to be told WordPress building, and customers making an attempt experimental options. By default WordPress hides notices generated through PHP when executing code. Simply surroundings the debug mode to true will display you those notices. This supplies the most important knowledge to builders to to find insects.


outline('WP_DEBUG', false);

Absolute Path Settings

The final a part of wp-config record defines absolutely the trail which is then used to setup WordPress vars and integrated information. You don’t want to trade the rest right here in any respect.


/** Absolute trail to the WordPress listing. */
if ( !outlined('ABSPATH') )
	outline('ABSPATH', dirname(__FILE__) . '/');
/** Sets up WordPress vars and integrated information. */
require_once(ABSPATH . 'wp-settings.php');

Useful wp-config.php Hacks and Settings

There are every other wp-config.php settings that help you troubleshoot mistakes and resolve many not unusual WordPress mistakes.

Changing MySQL Port and Sockets in WordPress

If your WordPress web hosting supplier makes use of trade ports for MySQL host, then you’ll want to trade your DB_HOST worth to come with the port quantity. Note, that this isn’t a brand new line however you want to edit the present DB_HOST worth.


outline( 'DB_HOST', 'localhost:5067' );

Don’t disregard to trade the port quantity 5067 to no matter port quantity is equipped through your internet host.

If your host makes use of sockets and pipes for MySQL, then you’ll want to upload it like this:


outline( 'DB_HOST', 'localhost:/var/run/mysqld/mysqld.sock' );

Changing WordPress URLs Using wp-config.php File

You might want to trade WordPress URLs when shifting a WordPress website to a brand new area identify or a brand new internet host. You can trade those URLs through visiting Settings » General web page.

WordPress Address and Site Address settings

You too can trade those URLs the usage of wp-config.php record. This comes at hand in case you are not able to get admission to the WordPress admin house due to error too many directs factor. Simply upload those two traces to your wp-config.php record:


outline('WP_HOME','http://instance.com');
outline('WP_SITEURL','http://instance.com');

Don’t disregard to exchange instance.com with your individual area identify. You additionally want to stay in thoughts that search engines like google and yahoo deal with www.instance.com and instance.com as two other places (See www vs non-www – Which one is healthier for search engine optimization?). If your website is listed with www prefix then you want to upload your area identify accordingly.

Change Uploads Directory Using wp-config.php

By default WordPress shops all of your media uploads in /wp-content/uploads/ listing. If you need to retailer your media information in someother location then you’ll be able to accomplish that through including this line of code in your wp-config.php record.


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

Note that the uploads listing trail is relative to the ABSPATH robotically set in WordPress. Adding an absolute trail right here is not going to paintings. See out detailed information on how to trade default media add location in WordPress for more info.

Disable Automatic Updates in WordPress

WordPress presented automated updates in WordPress 3.7. It allowed WordPress websites to robotically replace when there’s a minor replace to be had. While automated updates are nice for safety, however in some instances they may be able to ruin a WordPress website making it inaccessible.

Adding this unmarried line of code to your wp-config.php record will disable all automated updates in your WordPress website.


outline( 'WP_AUTO_UPDATE_CORE', false );

See our educational on how to disable automated updates in WordPress for more info.

Limit Post Revisions in WordPress

WordPress comes with built-in autosave and revisions. See our educational on how to undo adjustments in WordPress with put up revisions. However, should you run a big website revisions can build up your WordPress database backup measurement.

Add this line of code to your wp-config.php record to prohibit the collection of revisions saved for a put up.


outline( 'WP_POST_REVISIONS', 3 );

Replace Three with the collection of revisions you need to retailer. WordPress will now robotically discard older revisions. However, your older put up revisions are nonetheless saved in your database. See our educational on how to delete previous put up revisions in WordPress.

We hope this text helped you find out how to edit wp-config.php record in WordPress and all of the cool issues you’ll be able to do with it. You may additionally need to see our article on 25+ extraordinarily helpful methods for WordPress purposes record.

If you really liked this text, then please subscribe to our YouTube Channel for WordPress video tutorials. You too can to find us on Twitter and Facebook.

Recent Articles

How To Set Different Wallpapers On Multiple Screens On MAC

Does this question pop in your head when you think of setting up multiple screens on MAC? If so, the next few...

5 Must-Have Android Apps for 2020

The digitization of most of the amenities of society was a breakaway from the traditional livelihood of the masses.

How To Rearrange Comments in WordPress

Rearranging feedback to show the newest one on most sensible is changing into a brand new development that an increasing number of most sensible...

How to Highlight Author’s Comments in WordPress

On maximum websites, it is rather arduous for customers to observe creator’s feedback. This is why many WordPress websites spotlight their creator’s remark by...

How to Add Categories and Subcategories to WordPress

WordPress comes with the facility to kind your content material into classes, tags, and taxonomies. One of the most important distinction between classes and...

Related Stories

Leave A Reply

Please enter your comment!
Please enter your name here