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!


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.


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



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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.