Forum Moderators: open

Message Too Old, No Replies

Multiple Domains Multiple Databases

How to create dozens of databases for domains

         

ThumbsUp

1:07 am on Nov 2, 2008 (gmt 0)

10+ Year Member



Hi folks,

I am looking to create multiple databases for multiple domains right off the bat. Lets say I have 25 Domains and I would like to create database and database user for each of these domains. Creating one by one will take a lot of time so that I was wondering how to make this automated. I use cpanel, btw.

Thanks

S.

rocknbil

1:52 pm on Nov 2, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Welcome aboard ThumbsUp, by what I'm reading these domains are all on the same dedicated server/VPS, is this correct?

A more compact solution might be this:

main_table
rec_id¦domain_id¦fld1-common-to-all¦fld2-common-to-all.....

sites_table
rec_id¦domain_id¦fld-1-domain-specific¦fld-2-domain-specific......

Then when you query any given domain, pass domain id and join. . . .

example.com?d=7

select main_table.*,sites_table.* from main_table,sites_table where main_table.domain_id=sites_table.domain_id and main_table.domain_id=7;

This will give you a more compact DB structure; main_table will only hold one instance of rows that would otherwise be duplicated in multiple databases. If you sell one of the domains, you export the site-specific table with just the values for that site.

Otherwise, automating create user shouldn't be too difficult - you just need one user that has those privileges and script it. But to create database, you'd have to have a script that can run as root (I think, or privileges to create database, and AFAIK, the user needs to be root.) If you can do that, it has the ability to create databases and you could automate that as well.

ThumbsUp

4:12 pm on Nov 2, 2008 (gmt 0)

10+ Year Member



Thanks RocknBill, and also thanks for the warm welcome.

I am not very experienced with databases and creating them, all I used to do is go to mysql interface on cpanel create a database and username and assign all priveleges to them. Now I need to do this maybe 100 times. The code you provided, where should I write this code and run?

Thanks

S.

rocknbil

3:07 pm on Nov 3, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I don't think you're going to be able to automate this from the web interface. You're going to need some server side scripting, and may even have troubles with the DB creation in respect to permissions.

ThumbsUp

3:09 pm on Nov 3, 2008 (gmt 0)

10+ Year Member



Thanks rocknbill, its unfortunate that I can't do this automated. :( Thanks anyways.