hadf
hadf

Reputation: 282

mysql encoding utf-8 not working

I changed charset of database, tables and columns into UTF-8 :

ALTER DATABASE dbname CHARACTER SET utf8 COLLATE utf8_general_ci;
ALTER TABLE collection CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci;
ALTER TABLE collection MODIFY title VARCHAR(50) CHARACTER SET utf8 COLLATE utf8_general_ci;

And I inserted data into this table.

insert into collection (title) values ('Enfants et bébés');

Actually, data is inserted from a .sql file which is encoded in UTF-8 :

source collections.sql

The trouble is that the encoding fails :

select * from collection
+----+------------------------+
| id | title                  |
+----+------------------------+
| 17 | Enfants et Bébés     |
+----+------------------------+

I don't understand what's wrong. Thank you for your help

Upvotes: 1

Views: 2516

Answers (1)

hadf
hadf

Reputation: 282

I found the solution. The trouble cames from mysql client which is not in UTF-8 :

SET NAMES utf8

Upvotes: 1

Related Questions