I've had a good trawl through search and Google, but can't get to grips with a problem. I don't know if it is possible, but here goes:

A friend asked me to install a few mods to his phpBB3 site. No problem. However, there were a few that required SQL tweaks. He has his site/DB on a private web server and doesn't know the host address for the DB. I can access the DB through a custom pHp script using localhost as host and his login credentials.

What I need to know:

Is there a MYSQL/PHP function that returns the server/host name or address? I want to remotely access the DB using SQLyog or Navicat. I'm not to happy using SQL strings in a form to get stuff done (a bit like whistling in the dark). pHpMyAdmin is not on the account and will not be installed.

Thanks in advance

8 Years
Discussion Span
Last Post by diafol

Well for the phpbb cms I will have a look for any hacks to do this but codewise it is the following line which needs to be configured weather you can do it though the config file or if a hack is needed:

mysql_connect('localhost', 'mysql_user', 'mysql_password');
//above needs to be changed to
mysql_connect('website.com', 'mysql_user', 'mysql_password');

So I will check out phpbb for you as it may be possible to do it through the config file.
I just tried installing phpbb3 from a remote database and it appears what you need to do is first install phpbb3 on the server which supports mysql and at the same time specify the domain instead of localhost as the connection address. Then after installation, confirm in the config.php file that mysql is set to load from the remote server (currently the current server) and is not set to localhost. After that, you may transfer all the files to the other server that hasn't got databases and should read the remote server as it was specified during installation. The reason why the files need to be installed on the server with mysql is because of a validator that checks what types of databases are available.

Votes + Comments
Thanks for the help

Thanks cwarn - I really appreciate the time taken to look into my problem. My problem is that the board has already been set up (since 2002) and was updated to phpBB3 a good while ago. Unfortunately, the DB host name is not known but resides on the same server as the site (one of many sites, so using the site url is no good). I need to find the name of the host to connect remotely. At present I have this dirty (truncated) form (taken down when not in use), which actually works:

if($_POST['cod'] == "xxxxxx"){
	$mewnbwn = stripslashes($_POST['sq']);
	if(!strstr(strtolower($mewnbwn),'delete') && !strstr(strtolower($mewnbwn),'update')){

		$dbhost = 'localhost';
		$dbname = 'xxxx';
		$dbuser = 'xxxx';
		$dbpasswd = 'xxxx';
		$link_id = mysql_connect($dbhost, $dbuser, $dbpasswd) or die('No link');
		mysql_select_db($dbname, $link_id);
		$cofnodion = mysql_query($mewnbwn) or die('No query run');
		echo "Query OK";

The form has 2 fields 'cod' (password for running the script) and 'sq' (SQL string to run). What I'm after is the hostname so I can use SQLyog/Navicat as a GUI from my machine. Is there an SQL or php function/command that will return the actual hostname?

Thanks again.


does the host have a helpscreen with the server names
ours is a cheap host and to avoid phone calls there is a page outside the control panel
that lists



Votes + Comments
Thanks for the help

If the server is configured to allow access from the outside world, then just use the ip of the machine to connect to it.

At least in terms of cPanel you need to add external hosts to the permissions for connections outside of localhost.
I *believe* DirectAdmin was/is the same way.

Votes + Comments
Thanks for the help - above and beyond the call of duty

AB: no urls with the hosting: its on a private server - the owner (of the webserver) isn't very clued up either. Bit of a cowboy job actually.

MS: The IP of the site doesn't allow ext. access when I tried it. There's no cPanel. I'm really at a loss.

Anyway, thanks for your input guys. If you can think of anything else, I'd really appreciate it, but I'm hoping the owner will come back to me soon with something concrete. I'm sorry I even offered to help my mate now!


Well, if you can execute commands against the server, you could try this:

GRANT ALL PRIVILEGES ON {database}.* TO '{username}'@'{ip address}' IDENTIFIED BY '{password}' WITH GRANT OPTION;

The options are pretty straight forward but just in case:

{database} = db name
{username} = login
{ip address} = YOUR ip address (http;//www.whatismyip.com) (Can use a % to indicate a wildcard aka 192.168.1.%)
{password} = the password

If that doesn't work it can also be achieved by using an INSERT if the user you are connecting to the server with has the appropriate permissions. Its all in the mysql docs with examples and such. Its a long shot but it might get you somewhere.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.