[mysql]修改collation为utf8_bin

原创
2019/10/31 08:44
阅读数 912
mysql默认字段值区分大小写:
character-set-server=utf8
collation-server=utf8_bin
init-connect='SET NAMES utf8;'

SELECT DEFAULT_CHARACTER_SET_NAME 'charset', DEFAULT_COLLATION_NAME 'collation' 
FROM information_schema.SCHEMATA WHERE SCHEMA_NAME = 'billing01';

SELECT DEFAULT_CHARACTER_SET_NAME 'charset', DEFAULT_COLLATION_NAME 'collation' ,SCHEMA_NAME
FROM information_schema.SCHEMATA;


mysql> SHOW CHARACTER SET LIKE 'utf8';
+---------+---------------+-------------------+--------+
| Charset | Description   | Default collation | Maxlen |
+---------+---------------+-------------------+--------+
| utf8    | UTF-8 Unicode | utf8_general_ci   |      3 |
+---------+---------------+-------------------+--------+
1 row in set (0.00 sec)
https://blog.csdn.net/ghosind/article/details/83692869


mysql启动报错:
2019-10-29T08:52:41.945012+08:00 0 [ERROR] [MY-010936] [Server] COLLATION 'utf8_bin' is not valid for CHARACTER SET 'utf8mb4'
2019-10-29T08:52:41.946520+08:00 0 [ERROR] [MY-010119] [Server] Aborting
必须加character-set-server=utf8

my.cnf加
init_connect='SET collation_connection = utf8_bin'
也不行。


SHOW CHARACTER SET LIKE 'utf8';
mysqld —-character-set-server=utf8mb4 —-collation-server=utf8mb4_bin
ALTER DATABASE database-name CHARACTER SET charset-name COLLATE collation-name;
ALTER DATABASE billing01 CHARACTER SET utf8 COLLATE utf8_bin;
ALTER DATABASE billing02 CHARACTER SET utf8 COLLATE utf8_bin;
ALTER DATABASE billing03 CHARACTER SET utf8 COLLATE utf8_bin;
ALTER DATABASE billing04 CHARACTER SET utf8 COLLATE utf8_bin;
https://www.cnblogs.com/benpao/p/11519029.html
展开阅读全文
打赏
0
0 收藏
分享
加载中
更多评论
打赏
0 评论
0 收藏
0
分享
返回顶部
顶部