Forum Moderators: open
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.
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.
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.