This script generate a script that allow you to convert the charset of a MySQL database into another one.
- Version: 0.1
- Licensed under: GPLv3+
- Python: 3+ or 2.7
- mysqlclient
First of all you needs modify charset_converter.py
.
#SQL config
db_host = 'yout_host' # Host address and port
db_user = 'Username' # Database username
db_password = 'Password' # User password
db_name = 'database_name' # Database name
#from_charset = 'latin1' # Current database character set
from_collation = 'latin1_swedish_ci' # Current database collation
to_charset = 'utf8' # Future database character set
#Script Config
gen_script_filename = "output.sql"
And then run.
python charset_converter.py
# CHANGE DATABASE CHARACTER SET
ALTER DATABASE wordpress CHARACTER SET utf8;
################################################################################
# wp_commentmeta
################################################################################
# CHANGE DEFAULT TABLE CHARACTER SET
ALTER TABLE wp_commentmeta CHARACTER SET utf8;
# meta_key
alter table wp_commentmeta change meta_key meta_key VARBINARY(255);
alter table wp_commentmeta change meta_key meta_key VARCHAR(255);
# meta_value
alter table wp_commentmeta change meta_value meta_value LONGBLOB;
alter table wp_commentmeta change meta_value meta_value LONGTEXT CHARACTER SET utf8;
- Catch ENUM