Ad Widget

Collapse

Import initial schema and data error,perhaps utf8

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • ggggsc
    Junior Member
    • Feb 2019
    • 23

    #1

    Import initial schema and data error,perhaps utf8

    I just set up a new zabbix server and mysql database,on two different hosts.
    I have copied the create.sql.gz file to db hosts,however ,when i run zcat on db hosts, there's an error:
    [root@zabbix-db ~]# zcat /usr/local/create.sql.gz | mysql -uzabbix -p zabbix
    Enter password:
    ERROR 1366 (HY000) at line 2313: Incorrect string value: '\xE2\x80\x99s i...' for column 'description' at row 1
    I do create the zabbix database using utf8, I dropped the table and recreated it ,still don't work.
    create database zabbix character set utf8 collate utf8_bin;


    what can I do , what character set should I use?
  • Atsushi
    Senior Member
    • Aug 2013
    • 2028

    #2
    It seems that the default character code used by MySQL client in your environment is not utf8. Please connect with the mysql command and execute as follows and check whether character_set_client etc is utf8.

    Code:
    > show variables like 'char%';
    +--------------------------+----------------------------+
    | Variable_name            | Value                      |
    +--------------------------+----------------------------+
    | character_set_client     | utf8                       |
    | character_set_connection | utf8                       |
    | character_set_database   | utf8                       |
    | character_set_filesystem | binary                     |
    | character_set_results    | utf8                       |
    | character_set_server     | utf8                       |
    | character_set_system     | utf8                       |
    | character_sets_dir       | /usr/share/mysql/charsets/ |
    +--------------------------+----------------------------+
    8 rows in set (0.00 sec)
    
    >
    Try setting the default character set in the my.cnf file, or add the option "--default-character-set=utf8" when executing the mysql command.

    I have added the following setting to the mysqld section of /etc/my.cnf.d/ server.cnf when I use Mariadb of OS standard in CentOS 7.

    Code:
    [mysqld]
    character-set-server = utf8
    collation-server     = utf8_bin
    skip-character-set-client-handshake
    innodb_file_per_table

    Comment


    • ggggsc
      ggggsc commented
      Editing a comment
      Thanks a lots for your help, it works now!
      In addition,
      my platform is centos7 & mysql8.0, the configure file located in /etc/my.cnf
Working...