title: MariaDB clients to use UTF-8 by default
body: <p>How do I get MariaDB clients to use UTF-8?  I don't have this problem with MySQL of the equivalent version.  <strong>I am trying to do this without issuing <code>SET NAMES</code> via the client.</strong>  I get latin1 with the cmd line client and php's mysqli driver.</p>
  
  <p>PHP mysqli_get_charset:</p>
  
  <pre><code>print_r(mysqli_get_charset($link));
  stdClass Object
  (
      [charset] =&gt; latin1
      [collation] =&gt; latin1_swedish_ci
      [dir] =&gt; 
      [min_length] =&gt; 1
      [max_length] =&gt; 1
      [number] =&gt; 8
      [state] =&gt; 1
      [comment] =&gt; 
  )
  </code></pre>
  
  <p>Here is the output from the command line client:</p>
  
  <pre><code>echo "show variables like 'char%';" | mysql -u root -p
  
  Variable_name   Value
  character_set_client    utf8
  character_set_connection        utf8
  character_set_database  latin1
  character_set_filesystem        binary
  character_set_results   utf8
  character_set_server    latin1
  character_set_system    utf8
  character_sets_dir      /usr/share/mysql/charsets/
  </code></pre>
  
  <p>Here is my my.cnf file.</p>
  
  <pre><code>[client]
  port            = 3306
  socket          = /var/run/mysqld/mysqld.sock
  default-character-set=utf8
  [mysqld_safe]
  socket          = /var/run/mysqld/mysqld.sock
  nice            = 0
  default-character-set=utf8
  [mysqld]
  user            = mysql
  pid-file        = /var/run/mysqld/mysqld.pid
  socket          = /var/run/mysqld/mysqld.sock
  port            = 3306
  basedir         = /usr
  datadir         = /var/lib/mysql
  tmpdir          = /tmp
  lc-messages-dir = /usr/share/mysql
  skip-external-locking
  default-character-set  = utf8
  default-collation      = utf8_general_ci
  character_set_server   = utf8
  collation_server       = utf8_general_ci
  init_connect='SET NAMES utf8'
  key_buffer              = 512M
  max_allowed_packet      = 64M
  thread_stack            = 192K
  thread_cache_size       = 8
  myisam-recover         = BACKUP
  query_cache_limit       = 4M
  query_cache_size        = 64M
  expire_logs_days        = 10
  max_binlog_size         = 100M
  [mysqldump]
  quick
  quote-names
  max_allowed_packet      = 64M
  default-character-set=utf8
  [mysql]
  no-auto-rehash  # faster start of mysql but no tab completition
  default_character_set=utf8
  [isamchk]
  key_buffer              = 128M
  [client-server]
  default-character-set=utf8
  [client-mariadb]
  default-character-set=utf8
  !includedir /etc/mysql/conf.d/
  </code></pre>