欧美一区二区三区,国内熟女精品熟女A片视频小说,日本av网,小鲜肉男男GAY做受XXX网站

linux如何修改mysql字符集

林子帆2年前11瀏覽0評論

Linux系統下,MySQL默認字符集是Latin1,但是在實際應用中,可能需要使用UTF-8等不同的字符集,下面介紹如何修改MySQL字符集。

1. 查看當前MySQL字符集

mysql>show variables like '%char%';
+--------------------------+--------------------------------------------------------+
| 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       | /usr/share/mysql-5.6.44-linux-glibc2.12/share/charsets/ |
+--------------------------+--------------------------------------------------------+

2. 修改MySQL配置文件

$ vim /etc/mysql/my.cnf

在[mysql]下添加如下代碼:

[mysql]
default-character-set=utf8

3. 重啟MySQL服務

$ service mysql restart

4. 驗證MySQL字符集是否修改成功

mysql>show variables like '%char%';
+--------------------------+-------------------------------------------------------+
| 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       | /usr/share/mysql-5.6.44-linux-glibc2.12/share/charsets/ |
+--------------------------+-------------------------------------------------------+

至此,MySQL字符集修改完成。