Change MySQL default character set to UTF-8 in my.cnf?
2016-03-14 11:24
555 查看
注: mysql 5.5.40-0ubuntu0.14.04.1 (Ubuntu) 可以按此修改编码。
For the recent version of MySQL,
causes a problem. It's deprecated I think.
As Justin Ball says in "Upgrade
to MySQL 5.5.12 and now MySQL won’t start , you should:
Remove that directive and you should be good.
Then your configuration file ('/etc/my.cnf' for example) should look like that:
Restart MySQL.
For making sure, your MySQL is UTF-8, run the following queries in your MySQL prompt:
First query:
The output should look like:
Second query:
And the query output is:
For the recent version of MySQL,
default-character-set = utf8
causes a problem. It's deprecated I think.
As Justin Ball says in "Upgrade
to MySQL 5.5.12 and now MySQL won’t start , you should:
Remove that directive and you should be good.
Then your configuration file ('/etc/my.cnf' for example) should look like that:
[mysqld] collation-server = utf8_unicode_ci init-connect='SET NAMES utf8' character-set-server = utf8
Restart MySQL.
For making sure, your MySQL is UTF-8, run the following queries in your MySQL prompt:
First query:
mysql> show variables like 'char%';
The output should look like:
+--------------------------+---------------------------------+ | 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/local/mysql/share/charsets/| +--------------------------+---------------------------------+
Second query:
mysql> show variables like 'collation%';
And the query output is:
+----------------------+-----------------+ | Variable_name | Value | +----------------------+-----------------+ | collation_connection | utf8_general_ci | | collation_database | utf8_unicode_ci | | collation_server | utf8_unicode_ci | +----------------------+-----------------+
相关文章推荐
- MySQL——启动后停止——错误编码3534
- 1、利用jdbc,连接mysql数据库
- mysql slave从库负载均衡方案选择
- mysql被sql注入的一次打脸经历
- MySQL5.7 Replication主从复制配置教程
- mysql 5.6搭建总结
- MySql 基本操作语法
- mysql 数据库连接(远程和本地原理同样)
- mysql计算两点经纬度之间的距离
- mysql查询字段名 跟注释
- mysql的数据导入导出的几种方法
- 在Ubuntu上源码安装MySQL+安装问题解决+安全优化
- mysql分页(ajax)
- mysql的环形主从配置
- MySQL用户管理、授权
- Navicat for MySQL 函数高级属性讲解
- 常用的mysql数据库命令
- mysql 修改密码
- mysql中delete table和truncate table的区别
- Mysql 存储过程 游标 例子