[ERROR] [Entrypoint]: mysqld failed while attempting to check config command was: mysqld --verbose --help --log-bin-index=/tmp/tmp.U5mA1fUcxe 2022-11-02T03:29:06.006434Z 0 [ERROR] COLLATION ‘utf8_unicode_ci’ is not valid for CHARACTER SET ‘latin1’
该错误是在linux环境下,通过docker启动mysql容器导致的,刚开始一直在卡在status
始终为Restarting(1)
状态,后来通过docker logs mysql
查看日志发现该错误,[ERROR] COLLATION ‘utf8_unicode_ci’ is not valid for CHARACTER SET ‘latin1’,详细错误信息如下:
2022-11-02 03:29:06+00:00 [ERROR] [Entrypoint]: mysqld failed while attempting to check config
command was: mysqld --verbose --help --log-bin-index=/tmp/tmp.U5mA1fUcxe
2022-11-02T03:29:06.006434Z 0 [ERROR] COLLATION 'utf8_unicode_ci' is not valid for CHARACTER SET 'latin1'
2022-11-02T03:29:06.007616Z 0 [ERROR] Aborting
2022-11-02 03:29:51+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 5.7.36-1debian10 started.
2022-11-02 03:29:51+00:00 [ERROR] [Entrypoint]: mysqld failed while attempting to check config
command was: mysqld --verbose --help --log-bin-index=/tmp/tmp.YqcL2kBe52
2022-11-02T03:29:51.628893Z 0 [ERROR] COLLATION 'utf8_unicode_ci' is not valid for CHARACTER SET 'latin1'
2022-11-02T03:29:51.630078Z 0 [ERROR] Aborting
2022-11-02 03:30:14+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 5.7.36-1debian10 started.
2022-11-02 03:30:14+00:00 [ERROR] [Entrypoint]: mysqld failed while attempting to check config
command was: mysqld --verbose --help --log-bin-index=/tmp/tmp.6JQgiZnIAn
2022-11-02T03:30:14.806193Z 0 [ERROR] COLLATION 'utf8_unicode_ci' is not valid for CHARACTER SET 'latin1'
2022-11-02T03:30:14.807313Z 0 [ERROR] Aborting
2022-11-02 03:30:39+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 5.7.36-1debian10 started.
2022-11-02 03:30:39+00:00 [ERROR] [Entrypoint]: mysqld failed while attempting to check config
command was: mysqld --verbose --help --log-bin-index=/tmp/tmp.xXrHm224WP
2022-11-02T03:30:39.209294Z 0 [ERROR] COLLATION 'utf8_unicode_ci' is not valid for CHARACTER SET 'latin1'
2022-11-02T03:30:39.210850Z 0 [ERROR] Aborting
2022-11-02 03:39:46+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 5.7.36-1debian10 started.
2022-11-02 03:39:46+00:00 [ERROR] [Entrypoint]: mysqld failed while attempting to check config
command was: mysqld --verbose --help --log-bin-index=/tmp/tmp.t5KjmpUIhQ
2022-11-02T03:39:46.866732Z 0 [ERROR] COLLATION 'utf8_unicode_ci' is not valid for CHARACTER SET 'latin1'
2022-11-02T03:39:46.867833Z 0 [ERROR] Aborting
发现是由于在docker中配置mysql时其字符编码规则配置错误,原配置为:
[client]
default-character-set=utf8
[mysql]
default-character-set=utf8
[mysqld]
init_connect='SET collation_connection = utf8_unicode_ci' init_connect='SET NAMES utf8' character-set-server=utf8
collation-server=utf8_unicode_ci
skip-character-set-client-handshake
skip-name-resolve
而安装的mysql5.7版本的字符集编码默认为
show variables like 'character\_set\_%';
这里修改字符集配置,vi /mydata/mysql/conf/my.cnf
进入编辑修改
[client]
default_character_set=utf8
[mysql]
default-character-set=utf8
[mysqld]
collation_server = utf8_general_ci
character_set_server = utf8
skip-character-set-client-handshake
skip-name-resolve
重启mysql,docker restart mysql后查看日志发现没错误
问题解决