MySQL console client and multi-byte output problem

mysql> SELECT 'John Doe' as 'Джон Доу';
+-----------------+
| Джон Доу |
+-----------------+
| John Doe        |
+-----------------+
1 row in set (0.00 sec)
 
mysql> set NAMES utf8;
Query OK, 0 rows affected (0.00 sec)
 
mysql> SELECT 'John Doe' as 'Джон Доу';
+-----------------+
| Джон Доу |
+-----------------+
| John Doe        |
+-----------------+
1 row in set (0.00 sec)

Как видим set NAMES utf8 не помог. оказывается это старая проблема.

# mysql --default-character-set=utf8
 
mysql> SELECT 'John Doe' as 'Джон Доу';
+-----------------+
| Джон Доу        |
+-----------------+
| John Doe        |
+-----------------+
1 row in set (0.00 sec)

создаем конфиг для клиента

# cat ~/.my.cnf
[client]
default-character-set=utf8

Leave a Reply

Your email address will not be published. Required fields are marked *