File cấu hình my.cnf (Windows: my.ini) nằm thường ở C:\ProgramData\MySQL\MySQL Server X.Y\.
Các bước:
- Mở file bằng notepad (cần quyền Admin).
- Thêm/sửa đoạn
[mysqld]:
[mysqld] character-set-server = utf8mb4 collation-server = utf8mb4_unicode_ci
- Lưu file, khởi động lại dịch vụ MySQL (
net stop mysql && net start mysqlhoặc qua Services.msc).
Kiểm tra: SHOW VARIABLES LIKE 'character_set%';.
Khuyến nghị: Dùng utf8mb4 (hỗ trợ đầy đủ Unicode) thay vì utf8 cũ (chỉ 3 byte).