Can be done in a single command (rather than 148 of PHP):
mysql --database=dbname -B -N -e "SHOW TABLES"
| awk '{print "SET foreign_key_checks = 0; ALTER TABLE", $1, "CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci; SET foreign_key_checks = 1; "}'
| mysql --database=dbname &
You've got to love the commandline...
(You might need to employ the --user
and --password
options for mysql
).
EDIT: to avoid foreign key problems, added SET foreign_key_checks = 0;
and SET foreign_key_checks = 1;
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…