Current location: Hot Scripts Forums » Programming Languages » PHP » Access MySQL at another location?


Access MySQL at another location?

Reply
  #1 (permalink)  
Old 11-20-03, 10:12 AM
mqcarpenter mqcarpenter is offline
Newbie Coder
 
Join Date: Nov 2003
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Access MySQL at another location?

I have a client who's host does not have MySQL support, but has PHP (weird, I know).

I want to use a PHP script and let it access a MySQL DB that I have at another location. Do you know what the syntax for that would be? Sample code would be:

$isearch_sql_server = "localhost";
$isearch_sql_username = "user_name";
$isearch_sql_password = "password";
$isearch_sql_database = "database_name";

For the server, can I just put in the web address? Like, "www.mydomain.com" and put the DB name, user, etc?

TIA
Reply With Quote
  #2 (permalink)  
Old 11-20-03, 10:18 AM
mdhall's Avatar
mdhall mdhall is offline
Aspiring Coder
 
Join Date: Oct 2003
Posts: 510
Thanks: 1
Thanked 1 Time in 1 Post
Yes its possible, but not recommended. Theres a post already on this forum covering this same question, and explaining how and why.
Reply With Quote
  #3 (permalink)  
Old 11-20-03, 10:26 AM
mqcarpenter mqcarpenter is offline
Newbie Coder
 
Join Date: Nov 2003
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Quote:
Originally Posted by mdhall
Yes its possible, but not recommended. Theres a post already on this forum covering this same question, and explaining how and why.
Sometimes you do what you have to.

Any idea when it was posted, or what reference? I tried a few searchs and could not find it.

Thanks
Reply With Quote
  #4 (permalink)  
Old 11-20-03, 10:58 AM
mdhall's Avatar
mdhall mdhall is offline
Aspiring Coder
 
Join Date: Oct 2003
Posts: 510
Thanks: 1
Thanked 1 Time in 1 Post
Reply With Quote
  #5 (permalink)  
Old 11-20-03, 11:00 AM
Squid44th Squid44th is offline
Newbie Coder
 
Join Date: Nov 2003
Posts: 21
Thanks: 0
Thanked 0 Times in 0 Posts
Should be able, instead of:

$isearch_sql_server = "localhost";

use:

$isearch_sql_server = "http://www.mysqlhost.com";
Reply With Quote
  #6 (permalink)  
Old 11-20-03, 12:37 PM
NeverMind's Avatar
NeverMind NeverMind is offline
Community VIP
 
Join Date: Aug 2003
Location: K.S.A
Posts: 2,257
Thanks: 0
Thanked 2 Times in 1 Post
Quote:
Originally Posted by Squid44th
Should be able, instead of:

$isearch_sql_server = "localhost";

use:

$isearch_sql_server = "http://www.mysqlhost.com";
actually some servers don't allow remote mysql connections ... and some others accept them but you have to use special port for that ..
like :
http://www.mysql-server.com:2602 or whatever was the port ..
ask the host about it ...
__________________
PHPSimplicity
We don't need a reason to help people - Zidane [FF9]
Reply With Quote
  #7 (permalink)  
Old 11-20-03, 12:53 PM
mqcarpenter mqcarpenter is offline
Newbie Coder
 
Join Date: Nov 2003
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
I tried it and it is passing a username from the localhost instead of the one I specified, so it won't authenticate. Back to the drawing board!
Reply With Quote
  #8 (permalink)  
Old 11-20-03, 11:13 PM
jstanden jstanden is offline
Newbie Coder
 
Join Date: Oct 2003
Location: Orange County, California
Posts: 12
Thanks: 0
Thanked 0 Times in 0 Posts
You should also make sure the user you create has permission from remote domains.

Here's a quick SQL example of how to allow a user to connect from any remote domain:

GRANT ALL PRIVILEGES ON [database].* TO [user]@"%" IDENTIFIED BY '[password]';

You can replace "ALL PRIVILEGES" with a specific list if you desire, such as "SELECT,CREATE,UPDATE,ALTER,DELETE". You can also replace the '%' with a specific domain or mask -- the % is a wildcard or anything.

If you intend to connect from localhost as well, you'll need to create a separate account.

The above assumes you have MySQL console access, though you should be able to do the same thing with good control panels or a GUI like phpMyAdmin.

Thanks!
__________________
Jeff Standen, Chief of R&D, WebGroup Media LLC.
http://www.cerb4.com/ - Cerberus Helpdesk 4.2
Reply With Quote
  #9 (permalink)  
Old 11-21-03, 08:28 AM
mqcarpenter mqcarpenter is offline
Newbie Coder
 
Join Date: Nov 2003
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Quote:
Originally Posted by jstanden
You should also make sure the user you create has permission from remote domains.

Here's a quick SQL example of how to allow a user to connect from any remote domain:

GRANT ALL PRIVILEGES ON [database].* TO [user]@"%" IDENTIFIED BY '[password]';

You can replace "ALL PRIVILEGES" with a specific list if you desire, such as "SELECT,CREATE,UPDATE,ALTER,DELETE". You can also replace the '%' with a specific domain or mask -- the % is a wildcard or anything.

If you intend to connect from localhost as well, you'll need to create a separate account.

The above assumes you have MySQL console access, though you should be able to do the same thing with good control panels or a GUI like phpMyAdmin.

Thanks!
Good information. I will try that. Thank you
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
PHP and MySQL ? rob2132 Hot Scripts Forum Questions, Suggestions and Feedback 4 08-29-08 02:22 AM
Script Conversion: Access Database/Now to SQL PaniXOH ASP 1 11-14-03 09:35 PM
Is there any way I can link MS Access to a MySql on a remote web server (ISP)? xmxpcom PHP 2 11-12-03 03:33 AM
MySql to Access Db Import SmartCard Script Requests 0 10-24-03 03:02 PM
mysql to access aspuser25 Database 2 09-16-03 11:01 AM


All times are GMT -5. The time now is 05:56 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.