mysql数据库字符集合设置
mysql数据库字符集合设置
--------------------------停止和重新启动MySQL----------------------------
net stop mysql
net start mysql
查看mysql的字符集:
show variables like 'character%';
mysql设置编码命令:
SET character_set_client = utf8;
SET character_set_connection = utf8;
SET character_set_database = utf8;
SET character_set_results = utf8;
SET character_set_server = utf8;
SET collation_connection = utf8_bin;
SET collation_database = utf8_bin;
SET collation_server = utf8_bin;
修改my.ini中配置默认编码 :
default-character-set=utf8
连接数据库设置编码 :
jdbcDB.driverClassName=com.mysql.jdbc.Driver
jdbcDB.url=jdbc:mysql://localhost/user_test?useUnicode=true&characterEncoding=utf-8
mysql建库是设置字符集:
create database databaseName character set utf8;
修改数据库字符集:
alter database databaseName character set utf8;
mysql建表时指定字符集:
create table tableName(
字段名 类型
) engine=‘数据库引擎类型’ default charset=utf8;
修改表字符集:
alter table tableName default character set 'utf8';
其他命令:
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.建库时指定字符集
create database 数据库名 character set gbk collate gbk_chinese_ci;
- 点赞
- 收藏
- 关注作者
评论(0)