database on other server

database on other server

by Robert Bussell -
Number of replies: 4
What do I put in the dbhost option in the config.php file when the database is on another server?

Using mysql on a Linux/cPanel server.

Instead of localhost is it the ip address? The server's hostname?

Thanks!!!

Rob
Average of ratings: -
In reply to Robert Bussell

Re: database on other server

by Colin Fraser -
The ip address would be a good start - you think? It cannot be "localhost" and if your usual network usage protocol is to use named servers in all your references, then why would it be any different for this server? I am assuming here that your Moodle architecture is for the database to be on a completely separate computer, accessed across the network. I am also assuming that you are using something like MySQL Server.
In reply to Colin Fraser

Re: database on other server

by Robert Bussell -
The moodle files and moodledata are on one server, server1.domainname.com and I want to use a database on another server, server2.domainname.com.

Would the DBHost be server2.domainname.com or that sever's IP or something else?

Standard LAMP server running cPanel


In reply to Robert Bussell

Re: database on other server

by Colin Fraser -
Here is one solution which may or may not be of any value to you:

If you run SSH on the server, get an SSH client that does tunneling. Create a tunnel from your local machine on any port (3306 works well smile, to port 3306 (or whatever port MySQL is running on) on the remote computer. When you log the SSH session in (the ssh.com client can do tunnels only), you have "local" access to the database. As far as the system is concerned, you're local to it. As far as your client app is concerned, the DB is on localhost. As far as anyone else is concerned, the passwords and all traffic is encrypted.

And here is two web pages on SSH that may help you to understand how you can do it. Although the second is about Windows, the same principles will apply.
In reply to Robert Bussell

Re: database on other server

by Colin Fraser -
Now I can read the comment properly, is it your user dbase you are accessing? Usually it is the moodledata and userdb, that are found on other servers, however, the tunneling option should still work. This is a fairly esoteric use of the network though, and it may be that the additional complexity is going to open the Moodle and its database to some unforeseen vulnerability, or perhaps expose the essential fragility of the network. Is it worth it or would a better option be that the database on the other server is either duplicated (or mirrored perhaps) on your Moodle server. The more complex the system, the less robust it is, the more vulnerable it becomes, so it it worth a potentially higher risk?