Home > Database > Mysql Tutorial > mysql数据库的编码查看以及修改

mysql数据库的编码查看以及修改

WBOY
Release: 2016-06-07 15:53:11
Original
1243 people have browsed it

在mysql建表的时候经常碰到这个问题,就是中文插入的时候总是报错:很多情况下是因为你数据库或者表的编码不合适造成的: (1)可以通过 修改my.ini文件 文件进行修改:default-character-set=gb2312 (2)设定数据库字符集:alter database da_name default

在mysql建表的时候经常碰到这个问题,就是中文插入的时候总是报错:很多情况下是因为你数据库或者表的编码不合适造成的:

(1)可以通过修改my.ini文件文件进行修改:default-character-set=gb2312

(2)设定数据库字符集:alter database da_name default character set 'charset'

(3)单独设置某个数据库编码:alter database testdb character set utf8;

(4)查看mysql支持的编码:show character set;

(5)设置成需要的编码:mysql>set names 'gbk';

(6)设置数据库编码:CREATE DATABASE `test2` DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci

(7)查看数据表中字符集设置: show full columns from tablename; 或者 show create table tablename\G; 

(8)某个字段编码设置:alter table `t_test` change `name` `name` varchar (255)  character set  utf8 collate utf8_general_ci null default null;


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