Last active
August 29, 2015 14:05
-
-
Save carltondickson/6180f965ad22474cf1a9 to your computer and use it in GitHub Desktop.
Mysql - Character and collation settings
This file contains 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
# Defaults, log in to command line and run these...clients like SQLYog may have already SET NAME utf8 so results would not necessarily show the defaults | |
SHOW VARIABLES LIKE "collation_database"; | |
+--------------------+-------------------+ | |
| Variable_name | Value | | |
+--------------------+-------------------+ | |
| collation_database | latin1_swedish_ci | | |
+--------------------+-------------------+ | |
SHOW VARIABLES LIKE "%character%"; | |
+--------------------------+----------------------------+ | |
| Variable_name | Value | | |
+--------------------------+----------------------------+ | |
| character_set_client | utf8 | | |
| character_set_connection | utf8 | | |
| character_set_database | latin1 | | |
| character_set_filesystem | binary | | |
| character_set_results | utf8 | | |
| character_set_server | latin1 | | |
| character_set_system | utf8 | | |
| character_sets_dir | /usr/share/mysql/charsets/ | | |
+--------------------------+----------------------------+ | |
SHOW VARIABLES LIKE "%collation%"; | |
+----------------------+-------------------+ | |
| Variable_name | Value | | |
+----------------------+-------------------+ | |
| collation_connection | utf8_general_ci | | |
| collation_database | latin1_swedish_ci | | |
| collation_server | latin1_swedish_ci | | |
+----------------------+-------------------+ | |
# Show character and collation information on databases, tables and columns | |
# For Schemas: | |
SELECT default_character_set_name FROM information_schema.SCHEMATA S | |
WHERE schema_name = "schemaname"; | |
# For Tables: | |
SELECT CCSA.character_set_name FROM information_schema.`TABLES` T, | |
information_schema.`COLLATION_CHARACTER_SET_APPLICABILITY` CCSA | |
WHERE CCSA.collation_name = T.table_collation | |
AND T.table_schema = "schemaname" | |
AND T.table_name = "tablename"; | |
# For Columns: | |
SELECT character_set_name FROM information_schema.`COLUMNS` C | |
WHERE table_schema = "schemaname" | |
AND table_name = "tablename" | |
AND column_name = "columnname"; | |
# Credit to http://kosalads.blogspot.ca/2013/03/mysql-55-how-to-change-mysql-default.html | |
# Credit to http://stackoverflow.com/questions/1049728/how-do-i-see-what-character-set-a-database-table-column-is-in-mysql |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment