今天我自己把一个从windows导出来的.sql文件想再导入到linux的unbutn中出现了筹码,下面我来给大家介绍一下我解决source导入中文乱码方法有需要了解的朋友可参考.
错误提示:就是中文全部显示乱码了.
解决方式:查询mysql设置.
- mysql> s
-
- c:Program FilesMySQLMySQL Server 5.0binmysql.exe Ver 14.12 Distrib 5.0.67,
- for Win32 (ia32)
- Connection id: 1
- Current database: common
- Current user: root@localhost
- SSL: Not in use
- Using delimiter: ;
- Server version: 5.0.67-community-nt MySQL Community Edition (GPL)
- Protocol version: 10
- Connection: localhost via TCP/IP
- Server characterset: utf8
- Db characterset: utf8
- Client characterset: utf8
- Conn. characterset: utf8
- TCP port: 3306
- Uptime: 1 min 23 sec
- Threads: 1 Questions: 14 Slow queries: 0 Opens: 13 Flush tables: 1 Open tab
- les: 7 Queries per second avg: 0.169
在导出mysql sql执行文件的时候,指定一下编码格式,代码如下:
mysqldump -uroot -p --default-character-set=utf8 mo(dbname) > E://xxxx.sql
导入的时候OK了.执行如下:
- mysql -u root -p
-
- use dbname
-
- source /root/newsdata.sql
注意:如果你是gbk我们只要设置成gbk就可以了,要看上面查出来你数据库编码了. |