Page 1 of 1

Site Split & change table prefix

Posted: Mon Oct 15, 2012 3:45 am
by PBlue
I have an internal site which has many contents and I want to split it into three sites.

The requirements:
(1) Site A duplicates to Site B
(2) Site A duplicates to Site C
(3) Change the table prefix from "site_a_" to "site_b_" for Site B
(4) Change the table prefix from "site_a_" to "site_c_" for Site C

Please advise how to do this.

Site A is using version 1.11.2.

Re: Site Split & change table prefix

Posted: Wed Oct 17, 2012 12:11 am
by applejack
For what reason do you want to do this ?

Re: Site Split & change table prefix

Posted: Wed Oct 17, 2012 2:04 am
by PBlue
[quote="applejack"]For what reason do you want to do this ?[/quote

Just to be clear and make less confusing.

Initially I put "Windows Howto" and "Linux Howto" into one site and now there are a lot of contents inside it and I want to split into two sites - one is Windows Howto and another is Linux Howto. Tables in Windows Howto site will start with "howto_windows_" and tables in Linux Howto will start with "howto_linux_".

Re: Site Split & change table prefix

Posted: Wed Oct 17, 2012 10:34 am
by applejack
Why not just use 3 different databases named accordingly if you can.

Re: Site Split & change table prefix

Posted: Wed Oct 17, 2012 10:57 am
by PBlue
Yes, I'm using three databases but I'm not sure if the table prefix names can be modified. If not, this is the acceptable solution as well.

Re: Site Split & change table prefix

Posted: Wed Oct 17, 2012 11:12 am
by applejack
You can call the table prefixes whatever you like.

Re: Site Split & change table prefix

Posted: Thu Oct 18, 2012 1:17 am
by PBlue
applejack wrote:You can call the table prefixes whatever you like.
Not sure if I need to modify the config.php:

$config['db_prefix'] = 'my_prefix_';

You mean just rename the tables with a new prefix and then restart Apache and cmsms will work?

Re: Site Split & change table prefix

Posted: Thu Oct 18, 2012 9:30 am
by applejack
Yes and yes you do need to change the config setting.

Re: Site Split & change table prefix

Posted: Fri Oct 19, 2012 3:11 am
by PBlue
applejack wrote:Yes and yes you do need to change the config setting.
I tried:
(1) renamed ALL the table prefix
(2) changed $config['db_name'] = 'my_new_prefix';
(3) restart MySQL & Apache

But CMS only show the first page and the rest of the contents are gone. It seems that there must be some programs in CMSMS that hard coded the table prefix.

So, there should be more to be done to rename table prefix.

Re: Site Split & change table prefix

Posted: Fri Oct 19, 2012 9:57 am
by applejack
Clear the cache in admin. Are you using mod rewrite for SEO friendly url's. Double check any htaccess and config files. Check server error logs. You can also switch on debug in the config file.

Re: Site Split & change table prefix

Posted: Mon Oct 22, 2012 3:59 am
by PBlue
applejack wrote:Clear the cache in admin. Are you using mod rewrite for SEO friendly url's. Double check any htaccess and config files. Check server error logs. You can also switch on debug in the config file.
Yes, cache cleared. I'm using "mod_rewrite" for pretty URL.

I tried a newly install cmsms and the contents are all gone after renamename of table prefixes.

Table prefixes before: new_install_
Table prefixed after rename: fresh_install_

Config.php:
...
$config['db_name'] = 'new_install'; <-- db name unchanged
$config['db_port'] = 0;
$config['db_prefix'] = 'fresh_install_'; <-- table prefix changed
...

After rename, both Apache and MySQL have been restarted.

Admin log:
Admin Log.png
Contents gone after rename:
contents-gone.png
Table structure error as shown by cmsms:
table_strcuture_error.png