How to Access and Edit wp-config.php File in WordPress

Have you perused a tutorial asking you to edit your wp-config file and don’t have the foggiest idea what it is? Well, we got you covered. This article will show you how to edit wp-config.php file in WordPress appropriately.

What is the wp-config.php file?

As the name recommends, this configuration file is important for all self-facilitated WordPress locales. In contrast to different files, the wp-config.php file isn’t worked with WordPress, however, is created specifically for your site during the installation cycle.

WordPress stores your data set information in the wp-config.php file. Without this information, your WordPress site won’t work, and you will experience an establishing blunder, which is a data set connection mistake. Besides the data set information, the wp-config.php file likewise contains a few other undeniable level settings. We will explain them later in this article.

Because this file contains a great deal of delicate information, it is suggested that you don’t screw with it except if you have no other decision. Yet, since you are reading this article, it implies that you really want to edit the wp-config.php file. The following are the steps to do this without messing things up.

Start of work

The principal thing you ought to do is make a full reinforcement of WordPress. The wp-config.php file is so significant for a WordPress site that a little slip-up can make your site inaccessible. You will require an FTP client to connect to your site. Windows users can install WinSCP or SmartFTP, and Mac users can attempt Transmit or CyberDuck. An FTP client permits you to transfer files between your server and your PC.

Connect to your site using an FTP client. You will require FTP login information which you can get from your web. If you don’t know your FTP login information, you can ask your web have for help. The wp-config.php file is generally situated in the main folder of your site with different folders like/wp-content.

On the money, click on the file and then select the download choice from the rundown. Your FTP client will now download the wp-config.php file to your PC. You can open and edit it using a basic content program like Notepad, Text Edit, or surprisingly better VS Code.

Understanding the wp-config.php file

Before we begin, we should investigate the full code of the default wp-config.php file. You can likewise see an illustration of this file here.

<?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');

Each part of the wp-config.php file is legitimate in itself. Practically all settings here are defined using static PHP.

define( 'constant_name' , 'value'); 

We should investigate each segment in the wp-config.php file.

MySQL settings in the wp-config.php file

Your WordPress data set connection settings to appear in the “MySQL settings” segment of the wp-config.php file. To fill this segment, you really want your MySQL has, data set name, information base username, and secret key.

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

You can get your data set information from your web hosting record’s cPanel under the Databases area marked.

If you can’t find your WordPress information base or MySQL username and secret phrase, then you ought to contact your web have.

Authentication keys and salts

Exceptional authentication keys and salts are security keys that assist with improving the security of your WordPress site. These are key major areas of strength for giving to user meetings and treats created by WordPress.

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

/**#@-*/

You can produce WordPress security keys and glue them here. This is particularly perilous if you are using your WordPress site. Changing the security keys will log out all right now signed-in users on your WordPress site and power them to log back in.

WordPress data set table prefix

As a matter of course, WordPress adds the wp_ prefix to all WordPress-made tables. Changing your WordPress data set table prefix to something random is prescribed. This makes it difficult for programmers to figure out your WordPress tables and saves you from some SQL injection assaults.

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

If it’s not too much trouble, note that you can’t change this incentive for an existing WordPress site.

WordPress troubleshooting mode

This setting is particularly useful for users trying to learn WordPress advancement and those experimenting with exploratory highlights. As a matter of course, WordPress hides notifications produced by PHP while running code. Essentially setting investigate mode to genuine will show you these notifications. This gives significant information to developers to find bugs.

define('WP_DEBUG', false);

Absolute path settings

The last piece of the wp-config file specifies the way to the text that will then be used to start WordPress and the files. You don’t have to transform anything here by any means.

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

Settings can be made in wp-config.php

Some other wp-config.php settings can help you investigate and settle numerous normal WordPress mistakes.

Change MySQL port and attachment in WordPress

If your WordPress hosting supplier uses substitute ports for MySQL, then you really want to change your DB_HOST to include the port number. Note that this is certainly not another line. However, you really want to edit the existing DB_HOST esteem.

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

Remember to change the port number 5067 to anything port number given by your web have. If your host uses attachments and lines for MySQL, you really want to add them as follows.

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

Change WordPress URLs using the wp-config.php file

While moving a WordPress webpage to another domain name or another web have might have to change WordPress URLs. You can change these URLs by visiting the Settings » General page.

You can likewise change these URLs using the wp-config.php file. This is useful if you can’t access the WordPress admin region because of too many divert mistakes. Just add these two lines to your wp-config.php file.

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

Remember to supplant example.com with your domain name. You ought to likewise recall that web search tools treat www.example.com and example.com as two different spots. If your site is indexed with the www prefix, then you ought to add your domain name accordingly.

Change the rundown of transfers using wp-config.php

Of course, WordPress stores every one of your media transfers in the wp-content/transfers/directory. If you have any desire to store your media files in a different area, you can do as such by adding this line of code to your wp-config.php file.

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

Note that the transfers directory way is connected with ABSPATH, which is automatically set in WordPress. Adding an outright way won’t work here.

Debilitate auto-update in WordPress

WordPress introduced automatic updates in WordPress 3.7. It permitted WordPress locales to update when there was a minor update automatically. While automatic updates are perfect for security, at times, they can crash a WordPress site and make it inaccessible.

Also see: How to Make a Video Header in WordPress

Adding this line of code to your wp-config.php file will debilitate all automatic updates on your WordPress site.

define( 'WP_AUTO_UPDATE_CORE', false );

For more information, see our tutorial on how to handicap auto-updates in WordPress.

Limit post edits in WordPress

WordPress accompanies worked in autosave and update. However, editing can increase the size of your WordPress information base reinforcement if you run an enormous site. Add this line of code to your wp-config.php file to restrict the number of edits and put something aside for a post.

define( 'WP_POST_REVISIONS', 3 );

Supplant the quantity of 3 duplicates you need to save. WordPress now disposes of old edits automatically. However, your old post modifications are as yet stored in your data set.

We trust this article will assist you with learning how to edit the wp-config.php file in WordPress and attempt every one of the cool things you can do with it without any problem.

You may also like...

Leave a Reply

Your email address will not be published.