为什么不能使用mysql utf8?

时间:2018-04-06 00:03:50

标签: mysql sql amazon-web-services

情况

我不能在终端sql上使用utf 8,如select * from tb where c1 = '' and c2 ';但我可以从网上接受utf 8。

尝试

我通过命令将character_set_server和character_set_server更改为utf8。除此之外,它最初是utf8。以下命令似乎是临时的,当您重新输入mysql时,设置值已恢复

mysql> SET character_set_server=utf8;
Query OK, 0 rows affected (0.00 sec)





mysql> show variables like 'character%';
+--------------------------+-------------------------------------------+
| Variable_name            | Value                                     |
+--------------------------+-------------------------------------------+
| character_set_client     | utf8                                      |
| character_set_connection | utf8                                      |
| character_set_database   | utf8                                      |
| character_set_filesystem | binary                                    |
| character_set_results    | utf8                                      |
| character_set_server     | utf8                                      |
| character_set_system     | utf8                                      |
| character_sets_dir       | /rdsdbbin/mysql-5.6.35.R1/share/charsets/ |
+--------------------------+-------------------------------------------+
8 rows in set (0.00 sec)

编辑文件

的my.cnf

$ sudo vi /etc/my.cnf




[mysqld]

#not working
character-set-server=utf8

为什么?

即使您通过命令输入更改设置值,在查看全局区域时几乎所有内容都是拉丁1,如下所示。但是,它可能会有所不同,因为我们可以从客户那里收到日语。

show global variables like 'character%';



mysql>  show global variables like 'character%';
+--------------------------+-------------------------------------------+
| Variable_name            | Value                                     |
+--------------------------+-------------------------------------------+
| character_set_client     | latin1                                    |
| character_set_connection | latin1                                    |
| character_set_database   | latin1                                    |
| character_set_filesystem | binary                                    |
| character_set_results    | latin1                                    |
| character_set_server     | latin1                                    |
| character_set_system     | utf8                                      |
| character_sets_dir       | /rdsdbbin/mysql-5.6.35.R1/share/charsets/ |
+--------------------------+-------------------------------------------+
8 rows in set (0.00 sec)

重新启动

另外,我没有有意识地重启Apache或db,但我选择退出登录状态并退出登录状态的方法,如退出和控制R,但是我必须重新启动它?由于某种原因,从经验法则无意义地重新开始有阻力。

谢谢

0 个答案:

没有答案