mysql 列排序规则_在MySQL中,更改所有表和列的排序规则

问题:mysql -B -N --host=localhost --user=root --password=secret

-e "select CONCAT('alter table ',TABLE_SCHEMA,'.',

TABLE_NAME,' charset=utf8mb4_bin;')

from information_schema.TABLES WHERE TABLE_SCHEMA = 'usda_nndsr';

select CONCAT('alter table ',TABLE_SCHEMA,'.',TABLE_NAME,' alter column ',

COLUMN_NAME,' charset=utf8mb4_bin;')

from information_schema.COLUMNS WHERE TABLE_SCHEMA ='usda_nndsr';" |

mysql --host=localhost --user=root --password=secret

但消息显示:mysql: mysql: [Warning] Using a password on the command line interface can be insecure.[Warning] Using a password on the command line interface can be insecure.

ERROR 1115 (42000) at line 1: Unknown character set: 'utf8mb4_bin'

我想要utf8mb4_bin,因为我听说MySQL utf8不是仅使用3个字节的真正utf8。

如何编辑查询或命令进行更改,

MySQL版本:$ mysql -V

mysql Ver 14.14 Distrib 5.7.32, for Linux (x86_64) using EditLine wrapper

答案1:

对应的字符集是utf8mb4。

5.5之前的版本没有字符集utf8mb4.

这将转换一个表的所有文本(VARCHAR和TEXT)列:ALTER TABLE table_name CONVERT TO CHARACTER SET utf8mb4;

相关文章

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值