Script Perfect

         Random snips of code and bugs

Multiple Sites or Domains, One Server, One DB

Posted by Tim On September - 2 - 2009

While messing around with some of my other sites I ran into a major problem. I had developed a great deal of conent for the main site and thought it would be great to make a seperate site for mobile users. The new site would of course be much smaller and compact but still allow the majority of data from the main site to be viewed.

When I started developing the mobile site  hit a brick wall, I could not connect to the database on my main site even though both sites were on the same server. I tried connecting to localhost as well as the IP address, specifying the db name or calling it from the query. Needless to say it tooks hours to figure out what was going on so here is my solution.

Note: These sites are hosted on a MediaTemple DV server which is a virtualized dedicated server run through PLESK. Each domain hosted on the server gets assigned it’s own db.

Log into the SSH terminal and go to your mySQL prompt by using the following command line:

mysql –uadmin –p`cat /etc/psa/.psa.shadow`

Your promt should now look like:

mysql>

Once you are in your mySQL prompt you can create a new user(which is what I did) or you can just modify an existing user.

To create a new user, replace your ip below, *** is the password:

CREATE USER 'username'@'255.255.255.255' IDENTIFIED BY '***';

Next we need to give prvileges to this user:

GRANT SELECT ,INSERT ,UPDATE ,DELETE ,CREATE ,DROP ,FILE , INDEX ,ALTER, EXECUTE ON * . * TO 'username'@'255.255.255.255' IDENTIFIED BY '***' WITH MAX_QUERIES_PER_HOUR 0 MAX_CONNECTIONS_PER_HOUR 0 MAX_UPDATES_PER_HOUR 0 MAX_USER_CONNECTIONS 0 ;

And finally we need to grant privileges to all the databases on the server:

GRANT ALL PRIVILEGES ON * . * TO 'username'@'255.255.255.255';

So now that the user is set up with all the correct privileges we can flush privileges and call this job done:

FLUSH PRIVILEGES;

Notes: Now I know this may not work for everyone and it is a rather generic setup but the above is meant to give you a starting point for opening up permissions accross a server. You will need to modify the above if you want only specific permissions given as well as access to only certain databases.

2,367 Responses to “Multiple Sites or Domains, One Server, One DB”

  1. Recent Blogrolls……

    [...] Blogpost: edit .. found this post pertaining to [...]…

  2. Check this out…

    [...] that is the end of this article. Here you’ll find some sites that we think you’ll appreciate, just click the links over[...]……

  3. Visitor recommendations…

    [...]one of our visitors recently recommended the following website[...]……

  4. car games says:

    Recent Blogroll Additions……

    [...]usually posts some very interesting stuff like this. If you’re new to this site[...]……

  5. Visitor recommendations…

    [...]one of our visitors recently recommended the following website[...]……

  6. Links…

    [...]Sites of interest we have a link to[...]……

  7. 5. sinif says:

    Blogs ou should be reading…

    [...]Here is a Great Blog You Might Find Interesting that we Encourage You[...]……

  8. Sites we Like……

    [...] Every once in a while we choose blogs that we read. Listed below are the latest sites that we choose [...]……

  9. Cool sites…

    [...]we came across a cool site that you might enjoy. Take a look if you want[...]……

  10. Check this out…

    [...] that is the end of this article. Here you’ll find some sites that we think you’ll appreciate, just click the links over[...]……

  11. Sources…

    [...]check below, are some totally unrelated websites to ours, however, they are most trustworthy sources that we use[...]……

  12. Hello…

    My wife and i got very thankful Michael managed to deal with his investigations through the entire precious recommendations he acquired in your web pages. It’s not at all simplistic to simply happen to be freely giving ideas which many people have bee…

  13. Check this out…

    [...] that is the end of this article. Here you’ll find some sites that we think you’ll appreciate, just click the links over[...]……

  14. program says:

    Links…

    [...]Sites of interest we have a link to[...]……

  15. program says:

    Superb website…

    [...]always a big fan of linking to bloggers that I love but don’t get a lot of link love from[...]……

  16. Learn Piano says:

    Links…

    [...]Sites of interest we have a link to[...]……

  17. Spindschloss says:

    Read was interesting, stay in touch……

    [...]please visit the sites we follow, including this one, as it represents our picks from the web[...]……

  18. Read was interesting, stay in touch……

    [...]please visit the sites we follow, including this one, as it represents our picks from the web[...]……

  19. Great website…

    [...]we like to honor many other internet sites on the web, even if they aren’t linked to us, by linking to them. Under are some webpages worth checking out[...]……

  20. Websites worth visiting…

    [...]here are some links to sites that we link to because we think they are worth visiting[...]……

  21. Read was interesting, stay in touch……

    [...]please visit the sites we follow, including this one, as it represents our picks from the web[...]……

  22. Websites worth visiting…

    [...]here are some links to sites that we link to because we think they are worth visiting[...]……

  23. Related……

    [...]just beneath, are numerous totally not related sites to ours, however, they are surely worth going over[...]……

  24. physicians says:

    Websites you should visit…

    [...]below you’ll find the link to some sites that we think you should visit[...]……

  25. Blogs ou should be reading…

    [...]Here is a Great Blog You Might Find Interesting that we Encourage You[...]……

  26. Recommeneded websites…

    [...]Here are some of the sites we recommend for our visitors[...]……

  27. auctions says:

    Related……

    [...]just beneath, are numerous totally not related sites to ours, however, they are surely worth going over[...]……

  28. Vipit says:

    Links…

    [...]Sites of interest we have a link to[...]……

  29. christian dating sites…

    Howdy! Someone in my Myspace group shared this website with us so I came to look it over. I’m definitely enjoying the information. I’m book-marking and will be tweeting this to my followers! Exceptional blog and amazing design and style….

  30. Great website…

    [...]we like to honor many other internet sites on the web, even if they aren’t linked to us, by linking to them. Under are some webpages worth checking out[...]……

  31. Read was interesting, stay in touch……

    [...]please visit the sites we follow, including this one, as it represents our picks from the web[...]……

  32. Websites we think you should visit…

    [...]although websites we backlink to below are considerably not related to ours, we feel they are actually worth a go through, so have a look[...]……

  33. Recommeneded websites…

    [...]Here are some of the sites we recommend for our visitors[...]……

  34. Blogs to visit…

    [...] Lots of men and women have total-time attribute and are destined to be undertaking an occupation swap [...]…

  35. dating singles…

    Thank you for the sensible critique. Me and my neighbor were just preparing to do a little research on this. We got a grab a book from our local library but I think I learned more clear from this post. I am very glad to see such great info being shared…

  36. Check this out…

    Thanks for this post. I think it may be useful for my business, please write sth else about it….

  37. Cool sites…

    [...]we came across a cool site that you might enjoy. Take a look if you want[...]……

  38. Recent Blogroll Additions……

    [...]usually posts some very interesting stuff like this. If you’re new to this site[...]……

  39. Read was interesting, stay in touch……

    [...]please visit the sites we follow, including this one, as it represents our picks from the web[...]……

  40. Cool sites…

    [...]we came across a cool site that you might enjoy. Take a look if you want[...]……

  41. Check this out…

    [...] that is the end of this article. Here you’ll find some sites that we think you’ll appreciate, just click the links over[...]……

  42. Sources…

    [...]check below, are some totally unrelated websites to ours, however, they are most trustworthy sources that we use[...]……

  43. Great website…

    [...]we like to honor many other internet sites on the web, even if they aren’t linked to us, by linking to them. Under are some webpages worth checking out[...]……

  44. Related……

    [...]just beneath, are numerous totally not related sites to ours, however, they are surely worth going over[...]……

  45. … [Trackback]…

    Wonderful work! This is the type of information that should be shared around the internet. Shame on Google for not positioning this post higher! Come on over and visit my website . Thanks =)…

  46. Great website…

    Here are some of the sites we recommend for our visitors…

  47. auto quotes says:

    Cool blog…

    [...]while the sites we link to below are completely unrelated to ours, we think they are worth a read, so have a look[...]…

  48. darmo seks says:

    seks…

    Cipeczki chetne do wyruchania za darmo….

Leave a Reply

Spam protection by WP Captcha-Free

About Me

I am an independent web developer and webmaster of many sites. The main goal of Script Perfect is to provide answers to some of the hard to find questions when it comes to website design and coding.

Twitter