943,770 Members | Top Members by Rank

Ad:
  • PHP Discussion Thread
  • Marked Solved
  • Views: 5530
  • PHP RSS
Feb 16th, 2009
0

MySQL server address NOT localhost

Expand Post »
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
Similar Threads
Sponsor
Featured Poster
Reputation Points: 1048
Solved Threads: 947
Sarcastic Poster
ardav is offline Offline
6,678 posts
since Oct 2006
Feb 17th, 2009
1

Re: MySQL server address NOT localhost

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:
php Syntax (Toggle Plain Text)
  1. mysql_connect('localhost', 'mysql_user', 'mysql_password');
  2. //above needs to be changed to
  3. 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.
---------------
Edit:
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.
Last edited by cwarn23; Feb 17th, 2009 at 4:09 am. Reason: added info
Sponsor
Featured Poster
Reputation Points: 410
Solved Threads: 258
Occupation: Genius
cwarn23 is offline Offline
3,004 posts
since Sep 2007
Feb 17th, 2009
0

Re: MySQL server address NOT localhost

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:

PHP Syntax (Toggle Plain Text)
  1. if($_POST['cod'] == "xxxxxx"){
  2. $mewnbwn = stripslashes($_POST['sq']);
  3. if(!strstr(strtolower($mewnbwn),'delete') && !strstr(strtolower($mewnbwn),'update')){
  4.  
  5. $dbhost = 'localhost';
  6. $dbname = 'xxxx';
  7. $dbuser = 'xxxx';
  8. $dbpasswd = 'xxxx';
  9.  
  10. $link_id = mysql_connect($dbhost, $dbuser, $dbpasswd) or die('No link');
  11. mysql_select_db($dbname, $link_id);
  12. $cofnodion = mysql_query($mewnbwn) or die('No query run');
  13. echo "Query OK";
  14. }else{
  15. echo "No UPDATES/DELETES";
  16. }
  17. }
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.
Sponsor
Featured Poster
Reputation Points: 1048
Solved Threads: 947
Sarcastic Poster
ardav is offline Offline
6,678 posts
since Oct 2006
Feb 17th, 2009
1

Re: MySQL server address NOT localhost

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

mail.[yoursitenam].com
smtp.[yoursitenam].com
mysqlhost.[yoursitenam].com
ftp.[yoursitenam].com
ssh.[yoursitenam].com
controlpanel.[yoursitenam].com

etc
Reputation Points: 562
Solved Threads: 368
Posting Maven
almostbob is offline Offline
2,970 posts
since Jan 2009
Feb 17th, 2009
1

Re: MySQL server address NOT localhost

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.
Last edited by mschroeder; Feb 17th, 2009 at 3:03 pm.
Sponsor
Reputation Points: 265
Solved Threads: 126
Practically a Master Poster
mschroeder is offline Offline
624 posts
since Jul 2008
Feb 17th, 2009
0

Re: MySQL server address NOT localhost

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!
Sponsor
Featured Poster
Reputation Points: 1048
Solved Threads: 947
Sarcastic Poster
ardav is offline Offline
6,678 posts
since Oct 2006
Feb 17th, 2009
0

Re: MySQL server address NOT localhost

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

sql Syntax (Toggle Plain Text)
  1. 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.
Sponsor
Reputation Points: 265
Solved Threads: 126
Practically a Master Poster
mschroeder is offline Offline
624 posts
since Jul 2008
Feb 17th, 2009
0

Re: MySQL server address NOT localhost

Thanks again will do. Will marked solved and apply Rep points.
Sponsor
Featured Poster
Reputation Points: 1048
Solved Threads: 947
Sarcastic Poster
ardav is offline Offline
6,678 posts
since Oct 2006

This thread is solved

Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in PHP Forum Timeline: Click on add to continue playing
Next Thread in PHP Forum Timeline: PHP friend Display





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC