Answer the question
In order to leave comments, you need to log in
How to set utf-8 in MySQL as default?
Hello.
Created a DB. A field with type varchar(20), tried to insert a string with a size of 7 characters (Cyrillic), knocks out the following:
ERROR 1366 (HY000): Incorrect string value: '\xD0\xA2\xD0\xB5\xD1\x80...' for column 'drink_name' at row 1
character_set_client | utf8 |
| character_set_connection | utf8 |
| character_set_database | latin1 |
| character_set_filesystem | binary |
| character_set_results | utf8 |
| character_set_server | latin1 |
| character_set_system | utf8 |
| character_sets_dir | /usr/share/mysql/charsets/
character_set_database | latin1
is this the default encoding of the database when it was created? How to change to utf-8? mysql Ver 14.14 Distrib 5.7.19, for Linux (x86_64)
Answer the question
In order to leave comments, you need to log in
Everything can be set to default. Open my.cnf
in the [client] section write:
then in the [mysqld] section you write:
character-set-server=utf8
collation-server=utf8_general_ci
init-connect="SET NAMES utf8"
skip-character-set-client-handshake
I always create a database and immediately change it to utf8_general_ci
CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE=InnoDB
In the MySQL Administrator program, change Latin1 to utf8.
Or run the MySQL Server Config Wizard. There on the next page there will be a choice of encodings.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question