WordPress with a remote database - LinuxHunt
15500
 

WordPress with a remote database

WordPress with a remote database

Connecting WordPress site with a remote database (Database on another server) is a simple task. I checked huge websites and videos for connecting the WordPress website with the remote database but unable to find a proper solution. But after huge research and development. I found the solution for connecting the database.  It is just a few steps to follow and the database will connect with your WordPress.

Steps are :
1 . check your remote database is working fine or not.

2. If you are using vps server then try to ping the database server IP. (its shows you the server can connect your database ) This step is important.

3. if you are installing fresh WordPress then you enter the Database name, database user and database password and in the last enter database server ip.

If you are connecting existing WordPress sites, then you have to change in the wp-cofig.php file and enter these details  Database name, database user and database password and in the last enter database server IP.

4. After that check your site on the web browser.

If you still facing the issue then check properly the details that you entered.

for the VPS server you still facing issues related to that then follow a few more steps.

  1. Check Firewall ( like Port and database IP)
  2. It is important that you were able to ping your database IP from your VPS server. then you will be able to connect the database.
  3. If  you have no MySQL on the server then you have to install MySQL client only to connect the remote database
  4. Check with simple PHP code of joining the database .

Script/code

<?php $conn=mysqli_connect(“databaseIP”,”database_user”,”database_password”,”databasename”); if(!$conn){                 echo “not connected”; }else{                 echo “Connected”; }               ?>

 Save this code by name.php  and upload it on server after that check if status is not connected then may be in your wordpress site having some code issue or database details are not correct and check firewall also.

One more thing you can check on VPS that code is connected or not.

[root@ns110 ~]#  php  /path of Scripit/code / name.php  


you will get a response.  
if the response is connected but on the web browser not connected.

Then type this command after that you will able to connect the database from the VPS server.

sudo setsebool -P httpd_can_network_connect 1

you can check in you php logs or apache logs ( /var/logs/httpd/error_log).

You will find the error which stoping the connectivity.

If you still facing issues just comment down I will help you.

4 Comments

Post A Comment

Get notified automatically by email when there is new content!
For Questions or Comments, Contact us: editor @ linuxhunt.com

You have successfully subscribed to the newsletter

There was an error while trying to send your request. Please try again.

LinuxHunt will use the information you provide on this form to be in touch with you and to provide updates.