Warning, the following is quite ugly, but does the job :)
A while back I needed to create an archive slave database from a half a terabyte myisam master and had space restrictions. I could not dump the db, load it, then drop keys (archive doesn’t support keys apart from a primary key on one column as of 5.1), alter engine etc (would take even longer than it took either way). So an ugly single liner came to mind and worked nicely too.
mysqldump -uuser -ppassword -h127.0.0.1 -P3306 dbname --master-data=1 | sed 's/ENGINE=MyISAM/ENGINE=archive/g' | grep -v '^ UNIQUE KEY' | grep -v '^ KEY' | perl -p0777i -e 's/,\n^\)/\n\)/mg' | mysql -uuser -ppassword -h127.0.0.1 -P3307 dbname
So what is it doing?
Broken down:
mysqldump -uuser -ppassword -h127.0.0.1 -P3306 dbname --master-data=1
–> extract the database with the master position
sed 's/ENGINE=MyISAM/ENGINE=archive/g'
–> change myisam with archive so as to spare an alter table later
grep -v '^ UNIQUE KEY'
–> remove unique keys
grep -v '^ KEY'
–> remove other indexes
perl -p0777i -e 's/,\n^\)/\n\)/mg'
–> after removing the indexes, any commas before the closing bracket need to be removed
mysql -uuser -ppassword -h127.0.0.1 -P3307 dbname
–> inserting it directly into the slave
Let me know if you have any other ideas, again, the above is definitely not the neatest way, but it does work.
Because Sharing Is Caring
PlanetMySQL Voting: Vote UP / Vote DOWN