How To Change the Database Port for WordPress

WordPress is an open source content management tool. It is written in PHP and MySQL. Sometimes it becomes necessary to change the database ports as it helps your website against port scans that can be done through port sniffing websites. By changing the port over time, you can add a layer of safety to your database. In this guide, we will explain how you can change the database port of your WordPress website by following these simple steps.


  • WordPress cPanel Credentials
  • FTP application
  • Text Editor (Sublime, Notepad)

Step 1:

Log into your cPanel provided by your web hosting company. You need to access the WordPress directory through the cPanel. You can access it through the File Manager in the cPanel or connect to the WordPress directory using a FTP application like Filezilla.

Step 2:

Click on File Manager. You will see a list of files and folders. You need to go inside the public_html folder to access the wp-config.php file.

Step 3:

Now, locate the wp-config.php file inside the public_html folder and right click to edit it. On clicking edit you will see a Text Editor box. Click Edit to make changes to wp-config.php file.

Step 4:

Search for the keyword DB_HOST. You will find a port address of the database after DB_HOST keyword. Change your new database port address and Click Save Changes.


By following these simple steps, you can easily change the database port of your WordPress site. This adds an extra layer of protection against sniffers.


Check out these top 3 WordPress hosting services:

Was this article helpful?