title: Encoding database and server
body: <p>I am importing data from outside into my database MYSQL using PHP Scripts. Encoding my database charset to utf8 from the query </p>
  
  <pre><code>ALTER DATABASE DEFAULT CHARSET 'utf8';
  </code></pre>
  
  <p>then i executed a query to see all charsets by </p>
  
  <pre><code>SHOW VARIABLES LIKE 'character_set%';
  </code></pre>
  
  <p>output is:</p>
  
  <pre><code>+--------------------------+----------------------------+
  | 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     | latin1                     |
  | character_set_system     | utf8                       |
  | character_sets_dir       | /usr/share/mysql/charsets/ |
  +--------------------------+----------------------------+
  8 rows in set (0.00 sec)
  </code></pre>
  
  <p>as we can see <code>character_set_database</code> is set to <code>utf8</code> but still if i write a code from my PHP Script to see the encoding as</p>
  
  <pre><code>echo $charset = mysql_client_encoding($cn);
  </code></pre>
  
  <p>the output is <code>latin1</code> . From the above query latin1 is for server only. Can anyone tell me what exactly i am missing as i am unable to encode my Chinese and Japaneses characters to database.</p>
  
  <p><strong>EDIT</strong>    </p>
  
  <p>I am importing a database from outside which have unicode characters as 我的上网主页 and 嶏紞鎴戠殑 in Chinese , Japaneses and other different languages.
  But when i import data to my database tables i get ????? instead of above characters. How can i encode these characters? Is it utf-8 or 16 and how i can recognize that which encoding will support these characters?</p>