MySQL server address NOT localhost

Thread Solved

Join Date: Oct 2006
Posts: 1,000
Reputation: ardav will become famous soon enough ardav will become famous soon enough 
Solved Threads: 129
ardav's Avatar
ardav ardav is offline Offline
Veteran Poster

MySQL server address NOT localhost

 
0
  #1
Feb 16th, 2009
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
"...the woods would be a very silent place if no birds sang except for the best"
All opinions count - unless you're a serial downvoter.
F'enw i yw Mr. Blaidd. Byddwch yn ofalus - dwi'n cnoi.
Reply With Quote Quick reply to this message  
Join Date: Sep 2007
Posts: 1,477
Reputation: cwarn23 has a spectacular aura about cwarn23 has a spectacular aura about cwarn23 has a spectacular aura about 
Solved Threads: 136
cwarn23's Avatar
cwarn23 cwarn23 is offline Offline
Nearly a Posting Virtuoso

Re: MySQL server address NOT localhost

 
1
  #2
Feb 17th, 2009
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:
  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
Try not to bump 10 year old threads as it can be really annoying.
Like php then read my website at http://syntax.cwarn23.net/
Star-Trek-Atlantis - now that's what I call a movie ^_^
My favourite PC. - MacGyver Fan
Bad english note: dis-iz-2b4u
Reply With Quote Quick reply to this message  
Join Date: Oct 2006
Posts: 1,000
Reputation: ardav will become famous soon enough ardav will become famous soon enough 
Solved Threads: 129
ardav's Avatar
ardav ardav is offline Offline
Veteran Poster

Re: MySQL server address NOT localhost

 
0
  #3
Feb 17th, 2009
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:

  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.
"...the woods would be a very silent place if no birds sang except for the best"
All opinions count - unless you're a serial downvoter.
F'enw i yw Mr. Blaidd. Byddwch yn ofalus - dwi'n cnoi.
Reply With Quote Quick reply to this message  
Join Date: Jan 2009
Posts: 1,349
Reputation: almostbob has a spectacular aura about almostbob has a spectacular aura about 
Solved Threads: 163
almostbob's Avatar
almostbob almostbob is offline Offline
Nearly a Posting Virtuoso

Re: MySQL server address NOT localhost

 
1
  #4
Feb 17th, 2009
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
Failure is not an option It's included free
If at first you dont succeed, join the club
Of course its always in the last place you look, you dont keep looking after you find it

Please mark solved problems, solved
Reply With Quote Quick reply to this message  
Join Date: Jul 2008
Posts: 148
Reputation: mschroeder is on a distinguished road 
Solved Threads: 25
mschroeder mschroeder is offline Offline
Junior Poster

Re: MySQL server address NOT localhost

 
1
  #5
Feb 17th, 2009
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.
If you're question/problem is solved don't forget to mark the thread as Solved!

-- Code I post is usually but not always tested. If it is tested it will be against 5.2.11 or 5.3.0
Reply With Quote Quick reply to this message  
Join Date: Oct 2006
Posts: 1,000
Reputation: ardav will become famous soon enough ardav will become famous soon enough 
Solved Threads: 129
ardav's Avatar
ardav ardav is offline Offline
Veteran Poster

Re: MySQL server address NOT localhost

 
0
  #6
Feb 17th, 2009
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!
"...the woods would be a very silent place if no birds sang except for the best"
All opinions count - unless you're a serial downvoter.
F'enw i yw Mr. Blaidd. Byddwch yn ofalus - dwi'n cnoi.
Reply With Quote Quick reply to this message  
Join Date: Jul 2008
Posts: 148
Reputation: mschroeder is on a distinguished road 
Solved Threads: 25
mschroeder mschroeder is offline Offline
Junior Poster

Re: MySQL server address NOT localhost

 
0
  #7
Feb 17th, 2009
Well, if you can execute commands against the server, you could try this:

  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.
If you're question/problem is solved don't forget to mark the thread as Solved!

-- Code I post is usually but not always tested. If it is tested it will be against 5.2.11 or 5.3.0
Reply With Quote Quick reply to this message  
Join Date: Oct 2006
Posts: 1,000
Reputation: ardav will become famous soon enough ardav will become famous soon enough 
Solved Threads: 129
ardav's Avatar
ardav ardav is offline Offline
Veteran Poster

Re: MySQL server address NOT localhost

 
0
  #8
Feb 17th, 2009
Thanks again will do. Will marked solved and apply Rep points.
"...the woods would be a very silent place if no birds sang except for the best"
All opinions count - unless you're a serial downvoter.
F'enw i yw Mr. Blaidd. Byddwch yn ofalus - dwi'n cnoi.
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC