Changing MySQL Database Settings in WordPress

WordPress MySQL Config

Do you need to point your new instance of MySQL Database to your WordPress site? Or how do you change authentication details with your database? Maybe changing username or password to access MySQL database?

Your WordPress site and MySQL database co-exist and are linked together as this two-tier relationship also known as front-end and back-end. You can store your content, posts, media & pages in one structured place and that’s MySQL’s job. And on the flip side, you have the WordPress front-end making it all look pretty and structured.

Ok, let’s have a look into how to keep this relationship happy and configured so that these two worlds can co-exist and serve your content to your audience.

If you host your site on Windows IIS the chances are you will find wp-config.php file in the root folder of your site’s file system (picture below).

WordPress webconfig

  1. Navigate to your site’s file system using your preferred FTP client, such as FileZilla.
  2. Find wp-config.php file and open it in text editor, such as Visual Studio Code or Notepad++.
  3. Locate define constants towards the top of the file.
  4. Edit the define constants with your secure values as per examples below.
// ** MySQL settings - You can get this info from your web host ** //
/** The name of the database for WordPress */
define( 'DB_NAME', 'DATABASE NAME' );

/** MySQL database username */
define( 'DB_USER', 'DATABASE USER NAME' );

/** MySQL database password */
define( 'DB_PASSWORD', 'DATABASE USER PASSWORD' );

/** MySQL hostname */
define( 'DB_HOST', 'DATABASE HOST' );
  1. Save wp-config.php file and test MySQL connection.

Word of caution, make sure you set the correct values, otherwise you will loose connectivity between your WordPress web-front and the back-end MySQL Database.

On a side note, if you are still in the mood of code or configuration changes, why not look at my other post explaining How to redirect HTTP to HTTPS on WordPress.

Marcin Narloch

Marcin Narloch

Creative and out-of-the-box thinker with strong interests and knowledge in technology and innovation.
WordPress HTTP to HTTPS Previous post Redirecting HTTP to HTTPS on WordPress
WordPress Google Analytics tracking plugin Next post Writing Custom Plugin for Google Analytics in WordPress

Leave a Reply

Your email address will not be published.