title: Syntax error or access violation: 1253 COLLATION 'utf8_unicode_ci' is not valid for CHARACTER SET 'utf8mb4'
body: <p>MySQL 5.6 database calling a stored procedure.</p>
  
  <p>I can find nowhere in the database where utf8mb4 is set on anything.</p>
  
  <pre><code>+----------------------+-----------------+
  | 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   |
  +----------------------+---------+-------------------+
  </code></pre>
  
  <p>I have checked and every table and every column is utf8_unicode_ci</p>
  
  <p>I have hand edited and run the SQL to create the stored procedures after ensuring that the server, database, all tables, etc are utf8 / utf8_unicode_ci.</p>
  
  <p>I have no idea where utf8mb4 could be coming from and I've run out of places to look.</p>
  
  <hr>
  
  <p>I did a mysqldump of the source database and to my surprise I see this in the resulting file:</p>
  
  <pre><code>...
  /*!50003 SET character_set_client  = utf8mb4 */ ;
  /*!50003 SET character_set_results = utf8mb4 */ ;
  /*!50003 SET collation_connection  = utf8mb4_general_ci */ ;
  ...
  </code></pre>
  
  <p>Yet all my settings are as above - no utf8mb4 to be found anywhere.  Where are these values coming from?  I'm running this from the MySQL CLI.</p>
  
  <hr>
  
  <p>Here are the settings in my my.cnf file:</p>
  
  <pre><code>[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
  </code></pre>
  
  <hr>
  
  <p>THe error occurs when called from PHP using PDO:</p>
  
  <pre><code>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] =&gt; test [1] =&gt; [2] =&gt; [3] =&gt; [4] =&gt; ) bind params: Array ( ) : SQLSTATE[42000]: Syntax error or access violation: 1253 COLLATION 'utf8_unicode_ci' is not valid for CHARACTER SET 'utf8mb4'
  </code></pre>
  
  <hr>
  
  <p>A mysqldump of the routines shows this:</p>
  
  <pre><code>/*!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)
  </code></pre>
  
  <p>I simply cannot see where the utf8mb4 is coming from.</p>
  
  <hr>
  
  <p>Not sure why this would matter, but I'm running MAMP 4.0.6.</p>