查看数据库字符集:

show database create dbname \G;

查看数据库表字符集:

show table create tbname \G;

查看现有数据库字符集设置:

show variables like 'character_set%';

临时修改字符集:

set names latin1|utf8;

-------------------------------------------

非生产环境:

alter database character xxx;

alter table tbname character xxx;

前提:已经有记录的的字符集数据是无法修改的,

 

生产环境更改字符集:

已经跑了一段时间的库修改

修改过程:

 

1、导出表结构

 

mysqldump  -d参数

 

2、修改表结构sql内容,替换字符集关键字 比如Latin1改成utf8

 

3、导出表数据,这个时候就不能写入数据了

 

--no-create-info 只导出创建语句

 

4、修改数据sql文件latin1到utf8

5、创建指定库

6、创建指定表

7、导入指定数据

 

相关文章:

  • 2022-01-06
  • 2021-12-27
  • 2022-12-23
  • 2021-08-29
  • 2021-06-30
猜你喜欢
  • 2022-12-23
  • 2022-01-01
  • 2022-12-23
  • 2021-11-28
  • 2021-09-11
  • 2022-01-13
相关资源
相似解决方案