Access MySQL at another location?

11-20-03, 10:12 AM
|
|
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
|

11-20-03, 10:18 AM
|
 |
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.
|

11-20-03, 10:26 AM
|
|
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
|

11-20-03, 10:58 AM
|
 |
Aspiring Coder
|
|
Join Date: Oct 2003
Posts: 510
Thanks: 1
Thanked 1 Time in 1 Post
|
|
|
|

11-20-03, 11:00 AM
|
|
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";
|

11-20-03, 12:37 PM
|
 |
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]
|

11-20-03, 12:53 PM
|
|
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!
|

11-20-03, 11:13 PM
|
|
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
|

11-21-03, 08:28 AM
|
|
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
|
|
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
|
|
|
| Thread Tools |
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|