mysql5.6 modified character encoding, Err:illegal mix of collations for operation ' Concat '
1. Cause of the problem: build the environment to initialize the MySQL when you see the MySQL configuration file [cloent] under the settings encoded as Default-character-set = UTF8, the main idea is the global configuration, in fact, still need to [mysqld] The Character_set_server = UTF8 parameter is added under the
2. Try online Processing:
Mysql> Show variables like ' collation_% ';
Mysql> Show variables like ' character_set_% ';
See the code: Latin1
Then try to modify it using the SET command: Set GLOBAL variable_name=utf8_general_ci; set GLOBAL Variable_name=utf8;
result in execution of stored procedure: Call Xx_ya_stats_xx _daily (2018-05-18,3); still error: illegal mix of collations for operation ' Concat '
Finally, check the encoding of the database, automatically revert to Latin1
3. Personal conclusion: MySQL used latin1 character encoding during initialization, resulting in the library table data inside the latin1 character encoding, although changed the global encoding, but the Library table data encoding is not changed to, resulting in failure.
4. Final Solution: Export the database backup, re-initialize the MySQL instance, and then import the data and return to normal.
5. Steps:
Export: Mysqldump-uroot-h ' 127.0.0.1 '-p3306-pxxx-e-R db_name > db_name. sql
Modify Sql:cat db_name. sql | Grep-v "ALTER DATABASE \db_name\ ' CHARACTER SET latin1 COLLATE latin1_swedish_ci;" > db_name_n Ew.sql
Initialize the same new instance: mysql_install_db--user=mysql--basedir=/usr/local/mysql--datadir=xxxxx
Set Password:mysql> grant all privileges on * * to ' root ' @ '% ' identified by ' XXXX ';
mysql> flush Privileges;
Change Password: mysqladmin-h127.0.0.1-uroot-p--port=3336 password "new_passwd"
Open event: SET GLOBAL event_scheduler = on;
See if the event opens:mysql> show variables like ' Event_scheduler ';
Create a database and specify the character encoding:mysql> create db_name DEFAULT CHARACTER SET UTF8 COLLATE utf8_general_ci;
Import Database: Mysql-uroot-h ' 127.0.0.1 '-p3306-pxxxx db_name < db_name_new.sql
Test: Call xx_ya_stats_xxxx_daily (2018-05-18,3);
View Code:
Mysql> Show variables like ' collation_% ';
Mysql> Show variables like ' character_set_% ';
mysql5.6 modified character encoding, Err:illegal mix of collations for operation ' Concat '