我有一个Wordpress网站随机显示如下错误:
WordPress database error: [Incorrect string value: '\xF0\x9F\x92\x97\xF0\x9F...' for column 'option_value' at row 1] UPDATE `wp_options` SET `option_value` = 'a:95:{
这是占位符网站;使用PhpMyAdmin将数据从现有实时导出到.sql文件中。我怀疑有某种字符编码问题?我已经导出了任何'默认可能和UTF8一样。在导入的数据库中,我已经尝试将字符编码和整理作为UTF8(它当前)以及'Latin1 ISO8899西欧'和'utf_general_ci'分别作为编码和整理,但没有运气。
我注意到在一段时间后我去网站时会发生错误。
我该怎么办? 谢谢!
答案 0 :(得分:2)
我最近写过a detailed guide on how to switch from MySQL’s utf8
to utf8mb4
。如果你按照那里的步骤,一切都应该正常工作。以下是该流程中每个步骤的直接链接:
答案 1 :(得分:1)
问题可能是编码不匹配。 utf8可以存储最多3个字节的字符,utf8mb4可以存储最多4个字节的字符。我猜你的.sql文件中的数据包含utf8不支持的稀有符号。尝试重新导入.sql文件,但将编码设置为utf8mb4。我不久前在Joomla遇到了同样的问题。
答案 2 :(得分:0)
I encountered the same problem today. After tried many times, I found out the reason and fix it at last. For applications that store data using the default MySQL character set and collation (latin1, latin1_swedish_ci), so you need to specify the character set and collation to utf8/utf8_general_ci when your create your database or table. e.g.: $sql = "CREATE TABLE " . $table_name . " ( id mediumint(9) NOT NULL AUTO_INCREMENT, bookname varchar(128) NOT NULL, author varchar(64) NOT NULL, PRIMARY KEY (id), KEY (bookname) )CHARACTER SET utf8 COLLATE utf8_general_ci;"; Reference: 《mysql create table problem? SOLVED!!!!!!!!!!!》 http://forums.mysql.com/read.php?121,193883,193883 《10.1.5. Configuring the Character Set and Collation for Applications》 http://dev.mysql.com/doc/refman/5.0/en/charset-applications.html Hoping this can help you.