Wordpress Install and Database on separate hosting?

I have a situation where it would be ideal to have the database on separate hosting. Just because the host of the current site does not offer mysql. I cannot move the site (for a company)

Can I install wordpress on current hosting in a sub domain and have the database on another host? I have never used anything except “localhost” in the wp-config file? Thank you!

Topic mysql database Wordpress

Category Web


This question to my opinion is very important. I still do research on how to store the data on a specific local RAID. I dont think there is going to be a lack of performance doing so. If wordpress is on a RAID-10 and the database on a RAID-5 HDD within local hardware I am curious to know what can be wrong?


Yes - absolutely. Simply enter the appropriate hostname and credentials in wp-config.php. Instead of the default localhost use the hostname provided by your database provider.

Example:

define( 'DB_HOST', 'mysql.example.com:3307' );

https://codex.wordpress.org/Editing_wp-config.php#Set_Database_Host


In theory you can. You can specify the hostname or ip address of the DB server and communicate with it.

In practice this is unlikely to work well because:

  1. Performance might suck. The speed of information transfer on the same server or in a LAN is much higher than what you will get when you need to communicate over the internet

  2. You will have to leave the DB open to attacks. DBs are rarely exposed directly to the internet and I am not sure how good is MySQL security track record, but even in the best case you will have to worry about attacks on two servers instead of one.

Short version: don't do it. If the hosting sucks you either need to go away or select a different CMS that fits better what you can get from the hosting

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.