ed Reply #1, 5 years, 7 months ago
Kind of obvious but may help some people as I couldn't find anything in the manager interface to do this. Long after installation I discovered I wanted multiple modx sites to share the same database. The obvious way is to give each site a unique prefix for the table names, I chose to use the company name. Trouble is the first one had prefix 'modx_' and I wanted to change it for tidyness.
So my database name was modx and the database owner was modx, using the mysql tee command I listed all the tables to a text file.
my approach was to put a procedure at the top like
exit the editor and run the script saving the output
Ed
So my database name was modx and the database owner was modx, using the mysql tee command I listed all the tables to a text file.
mysql -u modx -p modxI edited tempfile to remove noise characters and create a sql script to rename the tables
give password
tee tempfile;
show tables;
\q
my approach was to put a procedure at the top like
foo() {
echo RENAME OLDPFX_$1 TO NEWPFX_$1 ';'
}
then globally replace all occurrences of OLDPFX_ to 'foo 'exit the editor and run the script saving the output
sh tempfile >rename.sqlthen use mysql to do the renames
mysql -u modx -p modxFinally edit manager/includes/config.inc.php to change the table prefix to NEWPFX_
\. rename.sql
\q
Ed
