gerrit是怎么使用MySQL_解决Gerrit2使用mysql时中文乱码问题

主要问题出在数据库上,为了保证安装时不出问题使用了latin1,但使用过程中就出现中文乱码问题了,

有时在报错如:

java.sql.BatchUpdateException: Incorrect string value: '\xC9\xCF'

for column 'message' at row 1

Illegal mix of collations (latin1_bin,IMPLICIT) and

(utf8_general_ci,COERCIBLE) for operation '<='

为此,修改如下

vi /etc/my.cnf

[mysqld]

default-character-set=utf8

init_connect='SET NAMES utf8'

[client]

default-character-set=utf8

进入数据库mysql>,执行如下命令

ALTER DATABASE gitdb charset=utf8;

alter table account_diff_preferences

engine=innodb;

alter table account_external_ids engine=innodb;

alter table account_group_id engine=innodb;

alter table account_group_includes_by_uuid

engine=innodb;

alter table account_group_includes_by_uuid_audit

engine=innodb;

alter table account_group_members engine=innodb;

alter table account_group_members_audit

engine=innodb;

alter table account_group_names engine=innodb;

alter table account_groups engine=innodb;

alter table account_id engine=innodb;

alter table account_patch_reviews engine=innodb;

alter table account_project_watches engine=innodb;

alter table account_ssh_keys engine=innodb;

alter table accounts engine=innodb;

alter table change_id engine=innodb;

alter table change_message_id engine=innodb;

alter table change_messages engine=innodb;

alter table changes engine=innodb;

alter table patch_comments engine=innodb;

alter table patch_set_ancestors engine=innodb;

alter table patch_set_approvals engine=innodb;

alter table patch_sets engine=innodb;

alter table schema_version engine=innodb;

alter table starred_changes engine=innodb;

alter table submodule_subscriptions engine=innodb;

alter table system_config engine=innodb;

alter table tracking_ids engine=innodb;

ALTER TABLE account_diff_preferences CONVERT TO CHARACTER SET utf8

COLLATE utf8_general_ci;

ALTER TABLE account_external_ids CONVERT TO CHARACTER SET utf8

COLLATE utf8_general_ci;

ALTER TABLE account_group_id CONVERT TO CHARACTER SET utf8 COLLATE

utf8_general_ci;

ALTER TABLE account_group_includes_by_uuid CONVERT TO CHARACTER SET

utf8 COLLATE utf8_general_ci;

ALTER TABLE account_group_includes_by_uuid_audit CONVERT TO

CHARACTER SET utf8 COLLATE utf8_general_ci;

ALTER TABLE account_group_members CONVERT TO CHARACTER SET utf8

COLLATE utf8_general_ci;

ALTER TABLE account_group_members_audit CONVERT TO CHARACTER SET

utf8 COLLATE utf8_general_ci;

ALTER TABLE account_group_names CONVERT TO CHARACTER SET utf8

COLLATE utf8_general_ci;

ALTER TABLE account_groups CONVERT TO CHARACTER SET utf8 COLLATE

utf8_general_ci;

ALTER TABLE account_id CONVERT TO CHARACTER SET utf8 COLLATE

utf8_general_ci;

ALTER TABLE account_patch_reviews CONVERT TO CHARACTER SET utf8

COLLATE utf8_general_ci;

ALTER TABLE account_project_watches CONVERT TO CHARACTER SET utf8

COLLATE utf8_general_ci;

ALTER TABLE account_ssh_keys CONVERT TO CHARACTER SET utf8 COLLATE

utf8_general_ci;

ALTER TABLE accounts CONVERT TO CHARACTER SET utf8 COLLATE

utf8_general_ci;

ALTER TABLE change_id CONVERT TO CHARACTER SET utf8 COLLATE

utf8_general_ci;

ALTER TABLE change_message_id CONVERT TO CHARACTER SET utf8 COLLATE

utf8_general_ci;

ALTER TABLE change_messages CONVERT TO CHARACTER SET utf8 COLLATE

utf8_general_ci;

ALTER TABLE changes CONVERT TO CHARACTER SET utf8 COLLATE

utf8_general_ci;

ALTER TABLE patch_comments CONVERT TO CHARACTER SET utf8 COLLATE

utf8_general_ci;

ALTER TABLE patch_set_ancestors CONVERT TO CHARACTER SET utf8

COLLATE utf8_general_ci;

ALTER TABLE patch_set_approvals CONVERT TO CHARACTER SET utf8

COLLATE utf8_general_ci;

ALTER TABLE patch_sets CONVERT TO CHARACTER SET utf8 COLLATE

utf8_general_ci;

ALTER TABLE schema_version CONVERT TO CHARACTER SET utf8 COLLATE

utf8_general_ci;

ALTER TABLE starred_changes CONVERT TO CHARACTER SET utf8 COLLATE

utf8_general_ci;

ALTER TABLE submodule_subscriptions CONVERT TO CHARACTER SET utf8

COLLATE utf8_general_ci;

ALTER TABLE system_config CONVERT TO CHARACTER SET utf8 COLLATE

utf8_general_ci;

ALTER TABLE tracking_ids CONVERT TO CHARACTER SET utf8 COLLATE

utf8_general_ci;

目的就是保证都使用utf8编码,引擎使用innodb,目的就是为了保证索引长度大于1000时依然不出错。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值