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

数据库 MySQL
在使用MySQL数据库的过程中,有时我们需要修改MySQL字符集,下文就教您如何在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语句的使用方法

责任编辑:段燃 来源: 互联网
相关推荐

2010-10-14 11:52:38

MySQL字符集

2010-10-09 11:12:32

mysql默认字符集

2011-04-11 10:59:33

Oracle字符集

2010-11-24 10:52:57

Mysql字符集

2010-10-09 11:36:30

MySQL字符集

2010-06-07 16:09:58

MySQL字符集

2020-12-16 06:34:16

MySQL字符集服务器

2021-03-23 18:21:30

MySQL数据库字符集

2010-05-06 14:40:59

Oracle字符集

2011-04-07 15:58:59

MySQL字符集乱码

2010-05-06 18:01:07

Oracle Expr

2011-05-16 13:15:55

MySQL存储字符集

2010-06-13 16:17:26

MySQL改变字符集

2009-02-24 10:51:30

2010-04-13 13:33:37

Oracle字符集

2010-06-02 17:59:19

MySQL字符集

2010-10-09 10:57:22

MySQL默认字符集

2010-11-01 15:44:45

DB2字符集

2010-05-17 10:01:09

MySql字符集

2010-04-30 10:16:22

Oracle字符集
点赞
收藏

51CTO技术栈公众号