W
W
wbrapist2017-08-29 13:19:38
MySQL
wbrapist, 2017-08-29 13:19:38

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

Latin is approved.
Found some variables:
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/

I'm not particularly sure of the accuracy of my understanding, but character_set_database | latin1is this the default encoding of the database when it was created? How to change to utf-8?
Z.s.
mysql  Ver 14.14 Distrib 5.7.19, for Linux (x86_64)

It seems that I read that in mysql from some version utf-8 is already by default everywhere, but for some reason it’s not like that for me.

Answer the question

In order to leave comments, you need to log in

3 answer(s)
A
Andrey, 2017-08-29
@wbrapist

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

then in the [mysql] section you write:
then in the [mysqldump] section you write:
rebutny muscle then

M
Maxim Fedorov, 2017-08-29
@Maksclub

I always create a database and immediately change it to utf8_general_ci

CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE=InnoDB

A
Alexander Skusnov, 2017-08-30
@AlexSku

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 question

Ask a Question

731 491 924 answers to any question