# Working with terminal in mysql with different encodings on freebsd



## blind0ne (Jun 5, 2022)

Hello, I'm trying to "work" with KOI-8R scripts on new FreeBSD installation, but there is one problem, the Russian characters itself looks like mess. On Linux where my production server is, before accessing mysql I'm typing some magic "source 2koi", and on locale command have such:

```
# locale   
LANG=ru_RU.KOI8-R
LANGUAGE=russian
LC_CTYPE="ru_RU.KOI8-R"
LC_NUMERIC="ru_RU.KOI8-R"
LC_TIME="ru_RU.KOI8-R"
LC_COLLATE="ru_RU.KOI8-R"
LC_MONETARY="ru_RU.KOI8-R"
LC_MESSAGES="ru_RU.KOI8-R"
LC_PAPER="ru_RU.KOI8-R"
LC_NAME="ru_RU.KOI8-R"
LC_ADDRESS="ru_RU.KOI8-R"
LC_TELEPHONE="ru_RU.KOI8-R"
LC_MEASUREMENT="ru_RU.KOI8-R"
LC_IDENTIFICATION="ru_RU.KOI8-R"
LC_ALL=
```

How can I achieve this locale goal on FreeBSD, And what is happening  in the backend while wrong characters displayed?

Thanks


----------



## 6502 (Jun 6, 2022)

Read this:






						MySQL :: MySQL 8.0 Reference Manual :: 10.4 Connection Character Sets and Collations
					






					dev.mysql.com
				




There are separate settings for server/client/etc charset. I guess you are working from mysql console.


----------



## blind0ne (Jun 6, 2022)

The problem solved by typing "setenv LANG ru_RU.KOI8-R" in terminal, would like to understand the whole concept of interpreting data in different encodings more deeply. Thanks


----------



## Alain De Vos (Jun 6, 2022)

I don't know the details but I have this for Belgium,

```
LANG=nl_BE.UTF-8
LANGUAGE=nl_BE.UTF-8
LC_ADDRESS=nl_BE.UTF-8
LC_ALL=nl_BE.UTF-8
LC_COLLATE=nl_BE.UTF-8
LC_CTYPE=nl_BE.UTF-8
LC_IDENTIFICATION=nl_BE.UTF-8
LC_MEASUREMENT=nl_BE.UTF-8
LC_MESSAGES=nl_BE.UTF-8
LC_MONETARY=nl_BE.UTF-8
LC_NAME=nl_BE.UTF-8
LC_NUMERIC=nl_BE.UTF-8
LC_PAPER=nl_BE.UTF-8
LC_TELEPHONE=nl_BE.UTF-8
LC_TIME=nl_BE.UTF-8
```
For login class for postgres(ql) i have in /etc/login.conf , lang & LC_COLLATE set.

For mysql i have in my.cnf:

```
character_set_server=utf8mb4
collation_server=utf8mb4_unicode_ci
```


----------

