如何在my.ini中将character_set_database和collat​​ion_database设置为utf8? [英] How to set character_set_database and collation_database to utf8 in my.ini?

查看:308
本文介绍了如何在my.ini中将character_set_database和collat​​ion_database设置为utf8?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经google了很多关于这个问题。总之,这是我的 my.ini 看起来像:

I've googled a lot about this problem. To sum up, this is what my my.ini looks like:

sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES 

[client]
database = abcdef
user = root
password = XXXXXX
default-character-set = utf8

[mysql]
default-character-set=utf8

[mysqld]
character_set_server=utf8
max_connections = 200
init_connect='SET collation_connection = utf8_general_ci' 
init_connect='SET NAMES utf8' 

通过cmd进入mysql,并发出:显示变量像%character%;显示变量像%collat​​ion%; ,这是我得到:

When I get into mysql via cmd and issue: show variables like "%character%";show variables like "%collation%";, this is what I got:

+--------------------------+---------------------------------+
| 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     | utf8                            |
| character_set_system     | utf8                            |
| character_sets_dir       | D:\env\MySQL5.6\share\charsets\ |
+--------------------------+---------------------------------+
8 rows in set (0.00 sec)

+----------------------+-------------------+
| Variable_name        | Value             |
+----------------------+-------------------+
| collation_connection | utf8_general_ci   |
| collation_database   | latin1_swedish_ci |
| collation_server     | utf8_unicode_ci   |
+----------------------+-------------------+

我已经重新启动了MySQL服务,所以任何人都可以告诉我如何改变 character_set_database 以及 collat​​ion_database utf8 ?非常感谢。

I've already restart the MySQL service, so could anyone give me some idea on how to change character_set_database as well as collation_database to utf8? Thanks a lot.

推荐答案

这实际上不是 my.cnf (或 my.ini 在这种情况下)。 mySQL从数据库自己的排序规则(在创建时)获取此设置。为了获得内联的utf8编码,你可以这样做:

This actually isn't a setting in the my.cnf (or my.ini in this case). mySQL gets this setting from the database's own collation (when it was created). Inorder to get this inline with the utf8 encoding you want, do this:

ALTER DATABASE databasename CHARACTER SET utf8 COLLATE utf8_general_ci;

然后在mysql上重新启动(不记得如果它需要) p>

then do a restart on mysql (cant remember if its needed though), followed by a:

SHOW VARIABLES;

所有应该都很好,
希望有帮助!

All should be well, Hope that helps!

注意:我认为 default-character-set 5.5+),似乎使配置文件fidgety。

side note: i think default-character-set is deprecated now-a-days (mySQL 5.5+) and seems to make the config file fidgety.

这篇关于如何在my.ini中将character_set_database和collat​​ion_database设置为utf8?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆