installed MySQL's default character set is Latin1, in order to change its character set to the user needs (such as UTF8), you must change its relevant configuration file; Because Linux under the MySQL default installation directory is distributed under different files , not like windows in the same directory, just modify the My.ini file, after the restart will be effective; So let's look at Linux. mysql database files, configuration files, and command files are in different directories:
1, database directory, The database files that it creates are in that directory;
/var/lib/mysql/
2, configuration file (Mysql.server command and location of configuration file)
/usr/share/ MYSQL&NBSP
3, related commands (such as MySQL mysqladmin, etc.)
/usr/bin
4, startup scripts (such as the MySQL startup command)
/etc/rc.d/ INIT.D/&NBSP
View the default character set
#mysql-u root-p
# (enter password)
mysql> show variables like ' Cha Racter_set% ';
+--------------------------+----------------------------+
| variable_name | Value |
+--------------------------+----------------------------+
| character_set_client | Latin1 |
| character_set_connection | latin1 |
| character_set_database | latin1 |
| charact Er_set_filesystem | Binary |
| character_set_results | latin1 |
| character_set_server | Latin1 |
| character_set_system | UTF8 |
| character_sets_dir |/usr/share/mysql/charsets/| 
+--------------------------+----------------------------+
Modify Character Set modify/ETC/MY.CNF file
?
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21-22 |
#/etc/my.cnf [Client] Default-character-set=utf8 [mysqld] Datadir=/var/lib/mysql Socket=/var/lib/mysql/mysql.sock User=mysql # Disabling Symbolic-links is recommended to prevent assorted security risks symbolic-links=0 #default-CHARACTE R-set=utf8 Character-set-server=utf8 init_connect= ' Set NAMES UTF8 ' [MySQL] no-auto-rehash Default-character-set=utf8 [ Mysqld_safe] Log-error=/var/log/mysqld.log Pid-file=/var/run/mysqld/mysqld.pid |
Remember: The mysqld is Character-set-server=utf8, not Default-character-set=utf8.
Otherwise will report: Starting MySQL ... The server quit without updating PID file [failed]lib/mysql/localhost.localdomain.pid). exception
Restart the MySQL server so that the contents of its settings take effect
#/etc/init.d/mysql restart