For starters, open up your my.cnf file, generally located in /etc/my.cnf or /etc/mysql/my.cnf, and add the following lines to the appropriate sections:
- Código: Seleccionar todo
[client]
loose-default-character-set = utf8
[mysql]
loose-default-character-set = utf8
[mysqld]
collation-server = utf8_unicode_ci
loose-default-character-set = utf8
character-set-server = utf8
init-connect = 'SET NAMES utf8'
skip-character-set-client-handshake
Switching to UTF-8 in PHP
Open up your php.ini file, generally located in /etc/php.ini, /etc/php5/php.ini, or /etc/php5/apache2/php.ini, and add or replace the following line:
- Código: Seleccionar todo
default_charset = "UTF-8"
Switching to UTF-8 in Apache
If you use the Apache web server, you’ll also want to set UTF-8 as the default charset there as well. Generally speaking, you want to add the following tag to your httpd.conf value, but sometimes the config option is already set in an include file such as /etc/apache2/conf-available/charset.
- Código: Seleccionar todo
AddDefaultCharset UTF-8