- Install pv tool
- Install script
curl https://raw.githubusercontent.com/cloudposse/mysql_fix_encoding/4.0/fix_it.sh -o /usr/local/bin/mysql_latin_utf8.sh chmod +x /usr/local/bin/mysql_latin_utf8.sh
You should have exited db with some tables or fields in latin1 encoding.
-
Create
my.cnf
file with client default options.Example:
[client] database=app user=root password=1234 host=db.example.com
-
Check SQL query that would be applied
$ MY_CNF=/home/${user}/my.cnf /usr/local/bin/mysql_latin_utf8.sh
-
Run convert db with command
$ MY_CNF=/home/${user}/my.cnf /usr/local/bin/mysql_latin_utf8.sh | pv | sudo mysql --defaults-file=/home/${user}/my.cnf
You can override the default database name specified in my.cnf
by setting the environment variable DB
Example:
$ DB=new_db \
MY_CNF=/home/${user}/my.cnf \
/usr/local/bin/mysql_latin_utf8.sh | pv | \
sudo mysql --defaults-file=/home/${user}/.my.cnf new_db