在Laravel

时间:2017-10-09 14:28:19

标签: mysql database laravel-5 character-encoding collation

我正在使用外部数据库(只读)和本地数据库(测试系统)。

因此,每次从外部数据库获取数据时,我都会使用默认的空字符符“ ”获得异常警告。

在我的情况下如何修改数据库设置?感谢。

(3/3)QueryException

SQLSTATE [HY000]:常规错误:1366字符串值不正确:'\ xF8peri ...'代表第1行的'customer_name'列(SQL:插入customers id,{{ 1}},customer_name)值(10008,Ol ** n N *** n K ***t peAS,n *** n @ k *** t.no))

外部数据库

character_set_client = utf8

character_set_connection = latin1

character_set_database = utf8

character_set_filesystem = binary

character_set_results = latin1

character_set_server = utf8

character_set_system = utf8

collat​​ion_connection = utf8_general_ci

collat​​ion_database = latin1_swedish_ci

collat​​ion_server = latin1_swedish_ci

Server Mysql 5.1版。

内部数据库

character_set_client = utf8mb4

character_set_connection = utf8mb4

character_set_database = utf8mb4

character_set_filesystem = binary

character_set_results = utf8mb4

character_set_server = latin1

character_set_system = utf8

collat​​ion_connection = utf8mb4_general_ci

collat​​ion_database = utf8mb4_unicode_ci

collat​​ion_server = latin1_swedish_ci

SErver MySQL版本5.7.19

测试系统环境: Win10,WAMPSERVER(MySQL v5.7.19,PHP v7.1.9)

1 个答案:

答案 0 :(得分:0)

\ xF8是一种unicode,它不适用于latin和latin_swedish字符集。您必须将字符集更新为UTF8或UTF8mb4并将其归类为utf8_general_ci或utf8mb4_general_ci