语法错误或访问冲突:1253 COLLATION'utf8_unicode_ci'对CHARACTER SET'utf8mb4'无效

时间:2016-12-22 03:02:53

标签: mysql mamp

MySQL 5.6数据库调用存储过程。

我无法在数据库中找到任何地方设置utf8mb4的地方。

+----------------------+-----------------+
| Variable_name        | Value           |
+----------------------+-----------------+
| collation_connection | utf8_general_ci |
| collation_database   | utf8_unicode_ci |
| collation_server     | utf8_unicode_ci |
+----------------------+-----------------+

+--------------------------+----------------------------+
| Variable_name            | Value                      |
+--------------------------+----------------------------+
| character_set_client     | utf8                       |
| character_set_connection | utf8                       |
| character_set_database   | utf8                       |
| character_set_filesystem | binary                     |
| character_set_results    | utf8                       |
| character_set_server     | utf8                       |
| character_set_system     | utf8                       |
| character_sets_dir       | /usr/share/mysql/charsets/ |
+--------------------------+----------------------------+

+----------------------+---------+-------------------+
| database             | charset | collation         |
+----------------------+---------+-------------------+
| mydatabase           | utf8    | utf8_unicode_ci   |
+----------------------+---------+-------------------+

我已经检查过,每个表和每一列都是utf8_unicode_ci

在确保服务器,数据库,所有表等都是utf8 / utf8_unicode_ci后,我手工编辑并运行SQL来创建存储过程。

我不知道utf8mb4可能来自哪里,而且我已经没有地方可以看了。

我做了一个源数据库的mysqldump,令我惊讶的是我在生成的文件中看到了这个:

...
/*!50003 SET character_set_client  = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection  = utf8mb4_general_ci */ ;
...

然而我的所有设置都如上所述 - 在任何地方都找不到utf8mb4。这些价值来自哪里?我是从MySQL CLI运行的。

以下是my.cnf文件中的设置:

[mysqld]
collation-server = utf8_unicode_ci
init-connect='SET NAMES utf8'
character-set-server = utf8

[client]
default-character-set = utf8

[mysql]
default-character-set = utf8

使用PDO从PHP调用时发生错误:

execQuery PDO Error: SQL: [65] CALL spSearchCategory5Param(1, 0, 250, ? , ? , ? , ? , ? , @oRet) Params: 5 Key: Position #0: paramno=0 name=[0] "" is_param=1 param_type=2 Key: Position #1: paramno=1 name=[0] "" is_param=1 param_type=2 Key: Position #2: paramno=2 name=[0] "" is_param=1 param_type=2 Key: Position #3: paramno=3 name=[0] "" is_param=1 param_type=2 Key: Position #4: paramno=4 name=[0] "" is_param=1 param_type=2 values: Array ( [0] => test [1] => [2] => [3] => [4] => ) bind params: Array ( ) : SQLSTATE[42000]: Syntax error or access violation: 1253 COLLATION 'utf8_unicode_ci' is not valid for CHARACTER SET 'utf8mb4'

例程的mysqldump显示了这个:

/*!50003 SET sql_mode              = @saved_sql_mode */ ;
/*!50003 SET character_set_client  = @saved_cs_client */ ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection  = @saved_col_connection */ ;
/*!50003 DROP PROCEDURE IF EXISTS `spSearchItem5Param` */;
/*!50003 SET @saved_cs_client      = @@character_set_client */ ;
/*!50003 SET @saved_cs_results     = @@character_set_results */ ;
/*!50003 SET @saved_col_connection = @@collation_connection */ ;
/*!50003 SET character_set_client  = utf8 */ ;
/*!50003 SET character_set_results = utf8 */ ;
/*!50003 SET collation_connection  = utf8_general_ci */ ;
/*!50003 SET @saved_sql_mode       = @@sql_mode */ ;
/*!50003 SET sql_mode              = '' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `spSearchItem5Param`(IN iEnableSearchLog int, IN iSearchIncludeAlias int, IN iEnableAltGroupSort int, IN iCallCustomSearch int, IN iAbsoluteLimit int, IN tSearch1 TEXT character set utf8, IN tSearch2 TEXT character set utf8, IN tSearch3 TEXT character set utf8, IN tSearch4 TEXT character set utf8, IN tSearch5 TEXT character set utf8, OUT iretVal INT)

我根本无法看到utf8mb4的来源。

不确定为什么这很重要,但我正在运行MAMP 4.0.6。

0 个答案:

没有答案