Liunx环境下MySQL字符集的修改方法

MySQL字符集的修改在不同的环境下有不同的方法,下面为您介绍的是在Liunx环境下MySQL字符集的修改方法,如果您对此方面感兴趣的话,不妨一看。

Liunx下修改MySQL字符集:

1.查找MySQL的cnf文件的位置

 
 
 
  1. find / -iname '*.cnf' -print  
  2.  
  3. /usr/share/mysql/my-innodb-heavy-4G.cnf  
  4. /usr/share/mysql/my-large.cnf  
  5. /usr/share/mysql/my-small.cnf  
  6. /usr/share/mysql/my-medium.cnf  
  7. /usr/share/mysql/my-huge.cnf  
  8. /usr/share/texmf/web2c/texmf.cnf  
  9. /usr/share/texmf/web2c/mktex.cnf  
  10. /usr/share/texmf/web2c/fmtutil.cnf  
  11. /usr/share/texmf/tex/xmltex/xmltexfmtutil.cnf  
  12. /usr/share/texmf/tex/jadetex/jadefmtutil.cnf  
  13. /usr/share/doc/MySQL-server-community-5.1.22/my-innodb-heavy-4G.cnf  
  14. /usr/share/doc/MySQL-server-community-5.1.22/my-large.cnf  
  15. /usr/share/doc/MySQL-server-community-5.1.22/my-small.cnf  
  16. /usr/share/doc/MySQL-server-community-5.1.22/my-medium.cnf  
  17. /usr/share/doc/MySQL-server-community-5.1.22/my-huge.cnf  

2. 拷贝 small.cnf、my-medium.cnf、my-huge.cnf、my-innodb-heavy-4G.cnf其中的一个到/etc下,命名为my.cnf

 
 
 
  1. cp /usr/share/mysql/my-medium.cnf /etc/my.cnf 

#p#3. 修改my.cnf

 
 
 
  1. vi /etc/my.cnf 

在[client]下添加

 
 
 
  1. default-character-set=utf8 

在[mysqld]下添加
 

 
 
 
  1. default-character-set=utf8 

4.重新启动MySQL

 
 
 
  1. [root@bogon ~]# /etc/rc.d/init.d/mysql restart  
  2. Shutting down MySQL                                        [ 确定 ]  
  3. Starting MySQL.                                            [ 确定 ]  
  4. [root@bogon ~]# mysql -u root -p  
  5. Enter password:  
  6. Welcome to the MySQL monitor. Commands end with ; or \g.  
  7. Your MySQL connection id is 1  
  8. Server version: 5.1.22-rc-community-log MySQL Community Edition (GPL)  
  9.  
  10. Type 'help;' or '\h' for help. Type '\c' to clear the buffer.  

#p#5.查看MySQL字符集设置

 
 
 
  1. mysql> show variables like 'collation_%';  
  2. +----------------------+-----------------+  
  3. | Variable_name        | Value           |  
  4. +----------------------+-----------------+  
  5. | collation_connection | utf8_general_ci |  
  6. | collation_database   | utf8_general_ci |  
  7. | collation_server     | utf8_general_ci |  
  8. +----------------------+-----------------+  
  9. 3 rows in set (0.02 sec)  
  10.  
  11. mysql> show variables like 'character_set_%';  
  12. +--------------------------+----------------------------+  
  13. | Variable_name            | Value                      |  
  14. +--------------------------+----------------------------+  
  15. | character_set_client     | utf8                       |  
  16. | character_set_connection | utf8                       |  
  17. | character_set_database   | utf8                       |  
  18. | character_set_filesystem | binary                     |  
  19. | character_set_results    | utf8                       |  
  20. | character_set_server     | utf8                       |  
  21. | character_set_system     | utf8                       |  
  22. | character_sets_dir       | /usr/share/mysql/charsets/ |  
  23. +--------------------------+----------------------------+  
  24. 8 rows in set (0.02 sec)  
  25.  
  26. mysql> 
  27.  

 

 

 

【编辑推荐】

MySQL删除外键定义的方法

MySQL外键和参照完整性的联系

带参数的MySql存储过程

PHP中常用到的一些MySQL语句

mysql UPDATE语句的使用方法

THE END