title: utf8 in database - set default_charset in php.ini
body: <p>I have set utf8 in mysql database</p>
  
  <p>now it shows</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     | utf8                       |
  | character_set_system     | utf8                       |
  | character_sets_dir       | /usr/share/mysql/charsets/ |
  +--------------------------+----------------------------+
  
  
  +----------------------+-----------------+
  | Variable_name        | Value           |
  +----------------------+-----------------+
  | collation_connection | utf8_general_ci |
  | collation_database   | utf8_unicode_ci |
  | collation_server     | utf8_unicode_ci |
  +----------------------+-----------------+
  </code></pre>
  
  <p>I have the below in the php code</p>
  
  <pre><code>mysqli_query("SET NAMES 'utf8'");
  </code></pre>
  
  <p>and</p>
  
  <pre><code>$con = mysqli_connect('host','user','pass','database');
  mysqli_query($con,"SET NAMES 'utf8'");
  </code></pre>
  
  <p>Since I set utf8 in database, I am planning to remove </p>
  
  <pre><code>mysqli_query("SET NAMES 'utf8'");
  </code></pre>
  
  <p>and</p>
  
  <pre><code>mysqli_query($database,"SET NAMES 'utf8'");
  </code></pre>
  
  <p>from PHP code</p>
  
  <p>I was told that I can remove the above code but I need to add </p>
  
  <pre><code>mysqli_set_charset($con,"utf8");
  </code></pre>
  
  <p>in the PHP code.</p>
  
  <p>Instead of adding <code>mysqli_set_charset($con,"utf8")</code> in the code, can I set </p>
  
  <pre><code>default_charset = "UTF-8" 
  </code></pre>
  
  <p>in <code>php.ini</code>?</p>
  
  <p>my.cnf is</p>
  
  <pre><code>[client]
  default-character-set=utf8
  
  [mysqld]
  default-character-set=utf8
  default-collation=utf8_general_ci
  character-set-server=utf8
  collation-server=utf8_unicode_ci
  init-connect='SET NAMES utf8'
  </code></pre>