复制代码 代码如下:
mysqldump -uroot -p --default-character-set=utf8 dbname tablename > bak.sql
复制代码 代码如下:
mysql -uroot -p --default-character-set=utf8 dbname < bak.sql
复制代码 代码如下:
mysql> show variables like ‘%char%';
+————————–+—————————-+
| Variable_name | Value |
+————————–+—————————-+
| character_set_client | latin1 |
| character_set_connection | latin1 |
| character_set_database | latin1 |
| character_set_filesystem | binary |
| character_set_results | latin1 |
| character_set_server | gbk |
| character_set_system | utf8 |
| character_sets_dir | D:mysqlsharecharsets |
+————————–+—————————-+
复制代码 代码如下:
mysql>set character_set_database=utf8; ##设置默认的字符集为utf8
复制代码 代码如下:
mysql> select * from table into outfile ‘c:table.txt' where +条件
复制代码 代码如下:
mysql> show variables like ‘%char%';
+————————–+—————————-+
| Variable_name | Value |
+————————–+—————————-+
| character_set_client | latin1 |
| character_set_connection | latin1 |
| character_set_database | latin1 |
| character_set_filesystem | binary |
| character_set_results | latin1 |
| character_set_server | gbk |
| character_set_system | utf8 |
+————————–+—————————-+
mysql>set character_set_database=utf8; ##设置默认的字符集为utf8
复制代码 代码如下:
mysql>load data local infile ‘/home/table.txt' into table `table`;
复制代码 代码如下:
show variables like 'char%';
复制代码 代码如下:
[mysql]
default-character-set=gbk
[mysqld]
character-set-server=utf8
新闻热点
疑难解答