title: Saving emoji characters in mysql database
body: <p>I am trying to save some data on <strong><em>mysql</em></strong> database, input contains emoji characters like this :  '\U0001f60a\U0001f48d' and I'm getting this error:</p>
  
  <pre><code>1366, "Incorrect string value: '\\xF0\\x9F\\x98\\x8A\\xF0\\x9F...' for column 'caption' at row 1"
  </code></pre>
  
  <p>I searched over net and read a lot of answers include these:
  <a href="https://stackoverflow.com/questions/35125933/mysql-utf8mb4-errors-when-saving-emojis">MySQL utf8mb4, Errors when saving Emojis</a> or <a href="https://stackoverflow.com/questions/35125933/mysql-utf8mb4-errors-when-saving-emojis">MySQL utf8mb4, Errors when saving Emojis</a> or <a href="https://mathiasbynens.be/notes/mysql-utf8mb4#character-sets" rel="nofollow noreferrer">https://mathiasbynens.be/notes/mysql-utf8mb4#character-sets</a> or <a href="http://www.java2s.com/Tutorial/MySQL/0080__Table/charactersetsystem.htm" rel="nofollow noreferrer">http://www.java2s.com/Tutorial/MySQL/0080__Table/charactersetsystem.htm</a> but nothing worked !!</p>
  
  <p>I have different problems:</p>
  
  <p>here is mydb info:</p>
  
  <pre><code>mysql&gt; SHOW VARIABLES WHERE Variable_name LIKE 'character\_set\_%' OR Variable_name LIKE 'collation%';
  +--------------------------+--------------------+
  | Variable_name            | Value              |
  +--------------------------+--------------------+
  | character_set_client     | utf8mb4            |
  | character_set_connection | utf8mb4            |
  | character_set_database   | utf8mb4            |
  | character_set_filesystem | binary             |
  | character_set_results    | utf8mb4            |
  | character_set_server     | utf8               |
  | character_set_system     | utf8               |
  | collation_connection     | utf8mb4_general_ci |
  | collation_database       | utf8mb4_general_ci |
  | collation_server         | utf8_general_ci    |
  +--------------------------+--------------------+
  10 rows in set (0.00 sec)
  </code></pre>
  
  <p>I tried to change <code>character_set_server</code> value to <code>utf8mb4</code> by </p>
  
  <pre><code>mysql&gt;SET character_set_server = utf8mb4
  Query OK, 0 rows affected (0.00 sec)
  </code></pre>
  
  <p>But when restart <code>mysqld</code> everything revert !</p>
  
  <p>I don't have any <code>/etc/my.cnf</code>  file in also, and I edited <code>/etc/mysql/my.cnf</code> file instead.</p>
  
  <p>What should I do?
  How can I save emoji file in my database?</p>