数据库错误(MySQL) [英] Error in Database (MySQL)
问题描述
incorrect string value: \xF0\x9F\x92\x95
如何解决?当我输入产品数据时会发生这种情况
how to solve it? this happens when I enter product data
推荐答案
商品的字符集
列必须为utf8mb4。请提供 SHOW CREATE TABLE
进行确认。
The CHARACTER SET
of the column needs to be utf8mb4. Please provide SHOW CREATE TABLE
for confirmation.
此外,连接需要为utf8mb4(或 UTF-8
,具体取决于客户端语言)。让我们看一下连接参数。
Also, the connection needs to be utf8mb4 (or UTF-8
, depending on the client language). Let's see the connection parameters.
尝试以下解决方案。
我终于能够弄清楚问题。
我必须更改mysql配置中的某些设置my.ini
本文提供了很多帮助
http://mathiasbynens.be/notes/mysql-utf8mb4#character-sets
I was finally able to figure out the issue. I had to change some settings in mysql configuration my.ini This article helped a lot http://mathiasbynens.be/notes/mysql-utf8mb4#character-sets
首先我更改了字符在my.ini中设置为utf8mb4
接下来,我在mysql客户端中运行了以下命令
First i changed the character set in my.ini to utf8mb4 Next i ran the following commands in mysql client
SET NAMES utf8mb4;
ALTER DATABASE dreams_twitter CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci;
使用以下命令检查所做的更改
Use the following command to check that the changes are made
SHOW VARIABLES WHERE Variable_name LIKE 'character\_set\_%' OR Variable_name LIKE 'collation%';
这篇关于数据库错误(MySQL)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!