Home > Database > Mysql Tutorial > mysql 字符集设置查看_MySQL

mysql 字符集设置查看_MySQL

WBOY
Release: 2016-06-01 13:44:14
Original
823 people have browsed it

bitsCN.com

 

1.列出MYSQL支持的所有字符集:

SHOW CHARACTER SET;

 

2.当前MYSQL服务器字符集设置

SHOW VARIABLES LIKE 'character_set_%';

 

3.当前MYSQL服务器字符集校验设置

SHOW VARIABLES LIKE 'collation_%';

 

4.显示某数据库字符集设置

show create database 数据库名;

 

5.显示某数据表字符集设置

show create table 表名;

 

6.修改数据库字符集

alter database 数据库名default character set 'utf8';

 

7.修改数据表字符集

alter table 表名default character set 'utf8';

 

8.建库时指定字符集

create database 数据库名character set gbk collate gbk_chinese_ci;

 

9.建表时指定字符集

CREATE TABLE `mysqlcode` (

`id` TINYINT( 255 ) UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY ,

`content` VARCHAR( 255 ) NOT NULL

) TYPE = MYISAM CHARACTER SET gbk COLLATE gbk_chinese_ci;

 

库字符集,在my.cnf中缺少了如下代码:

[client]

default-character-set=utf8

[mysqld]

default-character-set=utf8

 

 

如果不加以上代码,那么即便MYSQL编译安装时指定的编码是UTF8,那么在建库时其默认编码仍是LATIN1,而由于字符集的继承性,库中的表也是LATIN1的了。

 

程序访问数据url参数:

 

jdbc:mysql://localhost:3306/testCharacter?autoReconnect=true&useUnicode=yes&characterEncoding=UTF8

bitsCN.com
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template