source导入数据库乱码怎么解决?

1.导出数据设置编码

mysqldump -u root -p dbname --default-character-set=gbk > base_user.sql;

2.导入数据

#查看数据库服务和客户端字符集 
mysql> status; 
Server characterset:    gbk 
Db     characterset:      gbk 
Client characterset:      latin1 
Conn. characterset:     latin1 
mysql> set names 'gbk';   //这样 
mysql> status; 
Server characterset:   gbk 
Db     characterset:     gbk 
Client characterset:     gbk 
Conn. characterset:    gbk 
#这时才能导数据 
mysql> source a.sql;


by 雪洁 2013-08-04 09:27:02 2033 views
我来说几句

相关文章