Web Analytics Made Easy -
StatCounter Access a database from different websites - CodingForum

Announcement

Collapse
No announcement yet.

Access a database from different websites

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Access a database from different websites

    Is it possible to access a MySQL database from a domain other than the domain that the database is phtsically on, and if so, how?

    For example, if my database is located on www.site1.com, and I want to access it from a script on www.site2.com, how do I do it? For arguments sake, assume both websites are physically located on the same server, and they share an IP address of 123.123.123.001.

    Also, what about if the 2 websites are on different servers physically?

    Thanks.

    Alan

  • #2
    Welcome here,

    It's all possible. You just need to specify from which servers the account needs to have access, when you create it.

    If the sites are located on the same server, and the mySQL server is also located on that server, then you can use 'localhost' to specify the server in your connectionstring for both sites.

    To acces from another server, you need to specify the IP or domain when you create the user. Inside your connectionstring, you then need to use the servers (where the mySQL server runs on) IP or hostname.

    Check out http://www.mysql.com/doc/en/GRANT.html or run a search here since this question is asked here several times before.
    Posting guidelines I use to see if I will spend time to answer your question : http://www.catb.org/~esr/faqs/smart-questions.html

    Comment

    Working...
    X