Skip to content

Instantly share code, notes, and snippets.

@mustafaturksavas
Last active March 4, 2017 09:52
Show Gist options
  • Select an option

  • Save mustafaturksavas/01b7bd0b1652cd657e244f6929a5a404 to your computer and use it in GitHub Desktop.

Select an option

Save mustafaturksavas/01b7bd0b1652cd657e244f6929a5a404 to your computer and use it in GitHub Desktop.
Command to convert collation of all tables inside a db to utf8 and bypass errors for empty date
mysql --user=db_user --password='db_pass' --database=db_name -B -N -e "SHOW TABLES" | awk '{print "SET SESSION sql_mode='NO_ENGINE_SUBSTITUTION';", "ALTER TABLE", $1, "CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci;"}' | mysql --user=db_user --password='db_pass' --database=db_name &
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment