DB collation and chartset setting in Mysql (in Laravel)

怎甘沉沦 提交于 2019-12-12 04:46:11

问题


I am using external DB(charset:latin1_swedish_ci, collation=latin1, MyISAM) with internal DB(utf8mb4_unicode_ci, utf8mb4, InnoDB).

  • customer_name : collation = utf8mb4_unicode_ci
  • customer_email : collation = utf8mb4_unicode_ci

So everytime I get the below exception warning when getting data from external DB.

How should I modify DB setting in my situation? Thanks.


(3/3) QueryException

SQLSTATE[HY000]: General error: 1366 Incorrect string value: '\xF8peri ...' for column 'customer_name' at row 1 (SQL: insert into customers (id, customer_name, customer_email) values (10008, Olsen Naen Klist�pe AS, naen@klist.no))


external DB

Internal DB


Test System : Win10(64bit), Mysql(v5.7.19, InnoDB), PHP(v7.1), Laravel(v5.4)


回答1:


If that was supposed to be ø, then you need do one of two things:

  • Switch the encoding of text in the client from latin1 to UTF-8.

  • Tell MySQL that the client is conversing in latin1.

Other charset debugging: Trouble with UTF-8 characters; what I see is not what I stored



来源:https://stackoverflow.com/questions/46640891/db-collation-and-chartset-setting-in-mysql-in-laravel

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!