Skip to content
This repository has been archived by the owner on Oct 26, 2020. It is now read-only.

LuqueDaniel/MySQLCharsetConverter

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 

Repository files navigation

MySQL Charset Converter

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+

Dependencies

Example of use

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
Result
# 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;

To do

  • Catch ENUM

License

See GPLv3 license.

About

Convert charset of MySQL database

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages