Created
May 29, 2019 05:20
-
-
Save joostvanveen/682412e1ff3e73e5209b823642fba02d to your computer and use it in GitHub Desktop.
Alter the charset and collation to UTF8 for a database and a table. Also inspects the default charset and collation for the entire database.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Inspect the default charset and collation for your database | |
SELECT default_character_set_name FROM information_schema.schemata WHERE schema_name = 'MYDATABASE_NAME'; | |
-- Alter the default charset and collation for your database | |
-- CAREFUL: when you change the charset for your database, make sure the data in your tables matches that character set. | |
-- If it is not, follow these steps: http://www.alphadevx.com/a/420-Converting-a-MySQL-database-from-latin1-to-utf8 | |
ALTER DATABASE MYDATABASE_NAME CHARACTER SET utf8 COLLATE utf8_general_ci; | |
-- Alter the default charset and collation for your database | |
ALTER TABLE MYTABLE_NAME CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment