Get the Official WPSaviour App Now!

Beginner’s GuideBlog

How to Edit wp-config.php File in WordPress

Did you learn a tutorial that asks you to edit your wp-config file, and you haven’t any concept what it’s? Nicely we’ve received you coated. On this article, we are going to present you the best way to correctly edit the wp-config.php file in WordPress.

What’s wp-config.php File?

Because the title suggests, it’s a configuration file that’s a part of all self-hosted WordPress websites.

Not like different recordsdata, wp-config.php file doesn’t come built-in with WordPress relatively it’s generated particularly on your website throughout the set up course of.

WordPress creating wp-config.php file during the installation

WordPress shops your database info within the wp-config.php file. With out this info your WordPress web site is not going to work, and you’ll get the ‘error establishing database connection‘ error.

Aside from database info, wp-config.php file additionally comprises a number of different high-level settings. We are going to clarify them later on this article.

Since this file comprises loads of delicate info, it is strongly recommended that you just don’t mess with this file until you could have completely no different selection.

However because you’re studying this text, it implies that it’s a must to edit wp-config.php file. Under are the steps to do it with out messing issues up.

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

Getting Began

Very first thing you should do is to create a whole WordPress backup. The wp-config.php file is so essential to a WordPress website {that a} tiny mistake will make your website inaccessible.

You have to an FTP client to hook up with your web site. Home windows customers can set up WinSCP or SmartFTP and Mac customers can strive Transmit or CyberDuck. An FTP shopper permits you to switch recordsdata between a server and your pc.

Hook up with your web site utilizing the FTP shopper. You have to FTP login info which you will get out of your net host. In the event you don’t know your FTP login info, then you’ll be able to ask your net host for help.

The wp-config.php file is often positioned within the root folder of your web site with different folders like /wp-content/.

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

Merely proper click on on the file after which choose obtain from the menu. Your FTP shopper will now obtain wp-config.php file to your pc. You may open and edit it utilizing a plain textual content editor program like Notepad or Textual content Edit.

Understanding wp-config.php file

Earlier than you begin, let’s check out the complete code of the default wp-config.php file. You may as well see a pattern of this file here.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
<?php
/**
 * The bottom configuration for WordPress
 *
 * The wp-config.php creation script makes use of this file throughout the
 * set up. You do not have to make use of the website, you'll be able to
 * copy this file to "wp-config.php" and fill within the values.
 *
 * This file comprises the next configurations:
 *
 * * MySQL settings
 * * Secret keys
 * * Database desk prefix
 * * ABSPATH
 *
 * @hyperlink https://codex.wordpress.org/Editing_wp-config.php
 *
 * @bundle WordPress
 */
// ** MySQL settings - You may get this data out of your net host
** //
/** The title 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 make use of in creating database tables. */
outline('DB_CHARSET', 'utf8');
/** The Database Collate sort. Do not change this if unsure. */
outline('DB_COLLATE', '');
/**#@+
 * Authentication Distinctive Keys and Salts.
 *
 * Change these to totally different distinctive phrases!
 * You may generate these utilizing the
{@hyperlink https://api.wordpress.org/secret-key/1.1/salt/
WordPress.org secret-key service}
 * You may change these at any time limit to
invalidate all current cookies.
This may drive all customers to must log in once more.
 *
 * @since 2.6.0
 */
outline('AUTH_KEY',         'put your distinctive phrase right here');
outline('SECURE_AUTH_KEY''put your distinctive phrase right here');
outline('LOGGED_IN_KEY',    'put your distinctive phrase right here');
outline('NONCE_KEY',        'put your distinctive phrase right here');
outline('AUTH_SALT',        'put your distinctive phrase right here');
outline('SECURE_AUTH_SALT', 'put your distinctive phrase right here');
outline('LOGGED_IN_SALT',   'put your distinctive phrase right here');
outline('NONCE_SALT',       'put your distinctive phrase right here');
/**#@-*/
/**
 * WordPress Database Desk prefix.
 *
 * You may have a number of installations in a single database for those who
give every
 * a singular prefix. Solely numbers, letters, and underscores
please!
 */
$table_prefix  = 'wp_';
/**
 * For builders: WordPress debugging mode.
 *
 * Change this to true to allow the show of notices
throughout growth.
 * It's strongly advisable that plugin and theme
builders use WP_DEBUG
 * of their growth environments.
 *
 * For info on different constants that can be utilized
for debugging,
 * go to the Codex.
 *
 * @hyperlink https://codex.wordpress.org/Debugging_in_WordPress
 */
outline('WP_DEBUG', false);
/* That is all, cease enhancing! Completely satisfied running a blog. */
/** Absolute path to the WordPress listing. */
if ( !outlined('ABSPATH') )
    outline('ABSPATH', dirname(__FILE__) . '/');
/** Units up WordPress vars and included recordsdata. */
require_once(ABSPATH . 'wp-settings.php');

Every part of wp-config.php file is nicely documented within the file itself. Nearly all settings listed below are outlined utilizing PHP Constants.

1
outline( 'constant_name' , 'worth');

Let’s take a better take a look at every part in wp-config.php file.

MySQL Settings in wp-config.php File

Your WordPress database connection settings seem beneath ‘MySQL Settings’ part of the wp-config.php file. You have to your MySQL host, database title, database username and password to fill on this part.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
// ** MySQL settings - You may get this data from
your net host ** //
/** The title 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 make use of in creating database tables. */
outline('DB_CHARSET', 'utf8');
/** The Database Collate sort. Do not change this if unsure. */
outline('DB_COLLATE', '');

You may get your database info out of your website hosting account’s cPanel beneath the part labeled databases.

MySQL databases in cPanel

In the event you can not discover your WordPress database or MySQL username and password, then you should contact your net host.

Authentication Keys and Salts

Authentication distinctive keys and salts are safety keys that assist enhance safety of your WordPress website. These keys present a powerful encryption for person classes and cookies generated by WordPress. See our information on WordPress Security Keys for extra info.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
/**#@+
 * Authentication Distinctive Keys and Salts.
 *
 * Change these to totally different distinctive phrases!
 * You may generate these utilizing th
{@hyperlink https://api.wordpress.org/secret-key/1.1/salt/
WordPress.org secret-key service}
 * You may change these at any time limit to invalidate
all current cookies. This may drive all customers to must
log in once more.
 *
 * @since 2.6.0
 */
outline('AUTH_KEY',         'put your distinctive phrase right here');
outline('SECURE_AUTH_KEY''put your distinctive phrase right here');
outline('LOGGED_IN_KEY',    'put your distinctive phrase right here');
outline('NONCE_KEY',        'put your distinctive phrase right here');
outline('AUTH_SALT',        'put your distinctive phrase right here');
outline('SECURE_AUTH_SALT', 'put your distinctive phrase right here');
outline('LOGGED_IN_SALT',   'put your distinctive phrase right here');
outline('NONCE_SALT',       'put your distinctive phrase right here');
/**#@-*/

You may generate WordPress safety keys and paste them right here. That is notably helpful for those who suspect your WordPress website might have been compromised. Altering safety keys will logout all presently logged in customers in your WordPress website forcing them to login once more.

WordPress Database Desk Prefix

By default WordPress provides wp_ prefix to all of the tables created by WordPress. It is suggested that you just change your WordPress database desk prefix to one thing random. This may make it troublesome for hackers to guess your WordPress tables and can prevent from some widespread SQL injection assaults.

1
2
3
4
5
6
7
/**
 * WordPress Database Desk prefix.
 *
 * You may have a number of installations in a single database
for those who give every
 * a singular prefix. Solely numbers, letters, and
underscores please!
 */
$table_prefix  = 'wp_';

Please be aware that you just can not change this worth for an current WordPress website. Observe the directions in our the best way to change the WordPress database prefix article to alter these settings on an current WordPress website.

WordPress Debugging Mode

This setting is especially helpful for customers making an attempt to study WordPress growth, and customers making an attempt experimental options. By default WordPress hides notices generated by PHP when executing code. Merely setting the debug mode to true will present you these notices. This offers essential info to builders to search out bugs.

1
outline('WP_DEBUG', false);

Absolute Path Settings

The final a part of wp-config file defines absolutely the path which is then used to setup WordPress vars and included recordsdata. You don’t want to alter something right here in any respect.

1
2
3
4
5
/** Absolute path to the WordPress listing. */
if ( !outlined('ABSPATH') )
    outline('ABSPATH', dirname(__FILE__) . '/');
/** Units up WordPress vars and included recordsdata. */
require_once(ABSPATH . 'wp-settings.php');

Helpful wp-config.php Hacks and Settings

There are another wp-config.php settings that may assist you to troubleshoot errors and resolve many widespread WordPress errors.

Altering MySQL Port and Sockets in WordPress

In case your WordPress internet hosting supplier makes use of alternate ports for MySQL host, then you will want to alter your DB_HOST worth to incorporate the port quantity. Notice, that this isn’t a brand new line however you should edit the present DB_HOST worth.

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

Don’t neglect to alter the port quantity 5067 to no matter port quantity is supplied by your net host.

In case your host makes use of sockets and pipes for MySQL, then you will want so as to add it like this:

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

Altering WordPress URLs Utilizing wp-config.php File

It’s possible you’ll want to alter WordPress URLs when transferring a WordPress website to a brand new area title or a brand new net host. You may change these URLs by visiting Settings » Common web page.

WordPress Address and Site Address settings

You may as well change these URLs utilizing wp-config.php file. This comes useful in case you are unable to entry the WordPress admin space as a result of error too many directs concern. Merely add these two traces to your wp-config.php file:

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

Don’t neglect to interchange instance.com with your individual area title. You additionally have to remember that serps deal with www.instance.com and instance.com as two totally different areas (See www vs non-www – Which one is better for SEO?). In case your website is listed with www prefix then you should add your area title accordingly.

Change Uploads Listing Utilizing wp-config.php

By default WordPress shops all of your media uploads in /wp-content/uploads/ listing. If you wish to retailer your media recordsdata in someother location then you are able to do so by including this line of code in your wp-config.php file.

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

Notice that the uploads listing path is relative to the ABSPATH mechanically set in WordPress. Including an absolute path right here is not going to work. See out detailed information on the best way to change default media add location in WordPress for extra info.

Disable Automated Updates in WordPress

WordPress launched computerized updates in WordPress 3.7. It allowed WordPress websites to mechanically replace when there’s a minor replace obtainable. Whereas computerized updates are nice for safety, however in some circumstances they will break a WordPress website making it inaccessible.

Including this single line of code to your wp-config.php file will disable all computerized updates in your WordPress website.

1
outline( 'WP_AUTO_UPDATE_CORE', false );

See our tutorial on the best way to disable automatic updates in WordPress for extra info.

Restrict Submit Revisions in WordPress

WordPress comes with built-in autosave and revisions. See our tutorial on the best way to undo modifications in WordPress with submit revisions. Nonetheless, for those who run a big website revisions can improve your WordPress database backup dimension.

Add this line of code to your wp-config.php file to restrict the variety of revisions saved for a submit.

1
outline( 'WP_POST_REVISIONS', 3 );

Substitute Three with the variety of revisions you need to retailer. WordPress will now mechanically discard older revisions. Nonetheless, your older submit revisions are nonetheless saved in your database. See our tutorial on the best way to delete previous submit revisions in WordPress.

We hope this text helped you learn to edit wp-config.php file in WordPress and all of the cool issues you are able to do with it. You may additionally need to see our article on 25+ extremely useful tricks for WordPress functions file.

Download The WPSaviour App Now

Related posts
Beginner’s GuideBlogShowcase

7 Best Shopify Alternatives in 2020 (Cheaper and More Powerful)

Beginner’s GuideBest WordPress PluginsBlog

14 Best AI Chatbots Software for Your Website (Comparison)

Beginner’s GuideBlogTips

Magento vs WooCommerce – Which one is Better? (Comparison)

Beginner’s GuideBlogTips

12 Best Calculator Plugins for Your WordPress Site

Sign up for our Newsletter and
stay informed

Leave a Reply

Your email address will not be published.

Fear Of Missing Out?

Sign up with your email address to receive WordPress tips and updates
SUBSCRIBE NOW
Terms and Conditions apply
close-link
Click Me