昨天(應該是今天凌晨三點)恢復數據庫的時候,發生一個小插曲:
[root@site themes]# /usr/local/mysql/bin/mysql -uweb -p'admin' web </tmp/web_wp_20160422_687.sql
Warning: Using a password on the command line interface can be insecure.
ERROR 1366 (HY000) at line 907: Incorrect string value: '\xF0\x9F\x9B\xB3, ...' for column 'option_value' at row 1
查看下一下mysql的建表語句:
MySQL
mysql> show create table web.wp_users\G
*************************** 1. row ***************************
Table: wp_users
Create Table: CREATE TABLE `wp_users` (
`ID` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
`user_login` varchar(60) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '',
`user_pass` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '',
`user_nicename` varchar(50) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '',
`user_email` varchar(100) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '',
`user_url` varchar(100) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '',
`user_registered` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
`user_activation_key` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '',
`user_status` int(11) NOT NULL DEFAULT '0',
`display_name` varchar(250) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '',
PRIMARY KEY (`ID`),
KEY `user_login_key` (`user_login`),
KEY `user_nicename` (`user_nicename`),
KEY `user_email` (`user_email`)
) ENGINE=MyISAM AUTO_INCREMENT=2 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci
大概原因是字符集"utf8mb4"搞的鬼,遇到兩次字符集恢復數據庫的問題了
修復方法:
[client]
default-character-set=utf8mb4
[mysqld]
character-set-server=utf8mb4
停電了,utf8mb4這個字符集有很多新特性,不介紹了。請百度!