Last active
December 18, 2015 04:10
-
-
Save WebDragon/5723803 to your computer and use it in GitHub Desktop.
Saner Default settings for mysql config without which the universe generally is far more insane than it should be and data can be silently truncated at insert time with no warning whatsoever. Why mysql is not set to have these stricter settings by default is beyond me.
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
# NOTE also for mysql db driver connections like PDO, try and ensure the following | |
## init_connect = 'SET collation_connection = utf8_unicode_ci' | |
## init_connect = 'SET NAMES utf8' | |
## SET character_set_results=utf8; | |
## SET character_set_client=utf8; | |
## SET character_set_connection=utf8; | |
#~~~~~~ | |
[mysqld] | |
character-set-server = utf8 | |
collation-server = utf8_unicode_ci | |
init_connect='SET collation_connection = utf8_unicode_ci' | |
# without the following two settings MySQL can and will silently truncate | |
# data on insert without reporting this as an error and failing the row, | |
# among other annoyances. If your app breaks with these settings active, | |
# then your app is IMHO broken, and should be fixed to work more properly with | |
# a database that now does what it SHOULD do : | |
sql-mode='ANSI,TRADITIONAL,ONLY_FULL_GROUP_BY' | |
innodb_strict_mode='on' | |
[client] | |
default-character-set = utf8 | |
#~~~~~~ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
more people need to talk about this particular subject -- I am amazed at how little discussion there is of these two settings, and yet a great deal of the angst around and about regarding how bad and horrible mysql is, could be alleviated by simply coding your app and database to work within these strictures
the unicode related stuff is a toss-in that I added based on other factors I discovered while in the process of finding out about these, but all of those settings should be painstakingly set out in your db and your app to ensure that the entire connection maintains UTF-8-ness throughout.