MySQL 字符集设置
时间:2021-07-01 10:21:17
帮助过:2人阅读
**************************************************************************
* MySQL 字符集设置
* 说明:
* 数据库这块很多时候都会因为字符集不兼容导致数据通信异常,所以这边把
* MySQL的字符集设定为utf-8,这个比较通用。
*
* 2016-9-24 深圳 南山平山村 曾剑锋
**************************************************************************/
一、参考文档:
1. (原创)Linux下MySQL
5.5/
5.6的修改字符集编码为UTF8(彻底解决中文乱码问题)
http://www.ha97.com/5359.html
二、解决办法:
cat /etc/
my.cnf
......
[client]
......
default-character-
set=
utf8
......
[mysql]
......
default-character-
set=
utf8
......
[mysqld]
......
collation-server =
utf8_unicode_ci
init-connect=
’SET NAMES utf8′
character-
set-server =
utf8
......
三、查看结果:
[aplex@root ~]# mysql -u root -
p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.1.
73-
log Source distribution
Copyright (c) 2000,
2013, Oracle and/
or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/
or its
affiliates. Other names may be trademarks of their respective
owners.
Type ‘help;‘ or
‘\h‘ for help. Type
‘\c‘ to clear the current input statement.
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 | /usr/share/mysql/charsets/ |
+--------------------------+----------------------------+
8 rows
in set (
0.00 sec)
mysql>
quit
Bye
[aplex@root ~]#
MySQL 字符集设置
标签: