Home > Database > Mysql Tutorial > mysql 从文件导入sql 乱码问题..._MySQL

mysql 从文件导入sql 乱码问题..._MySQL

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-06-01 13:44:15
Original
769 people have browsed it

bitsCN.com

 

首先我拿到sql文件没乱码,(用ultraedit 管理员界面可以看到文件编码)

 

数据库编码和文件一致

 

下面就进到mysql里面看看variables

mysql> show variables like "%char%"; 

+--------------------------+---------------------------------------------------------------------------------+ 

| Variable_name            | Value                                                                           | 

+--------------------------+---------------------------------------------------------------------------------+ 

| character_set_client     | latin1                                                                          | 

| character_set_connection | latin1                                                                          | 

| character_set_database   | utf8                                                                            | 

| character_set_filesystem | binary                                                                          | 

| character_set_results    | latin1                                                                          | 

| character_set_server     | utf8                                                                            | 

| character_set_system     | utf8                                                                            | 

| character_sets_dir       | /usr/local/Percona-Server-5.1.57-rel12.8-233-Linux-x86_64/share/mysql/charsets/ | 

+--------------------------+---------------------------------------------------------------------------------+ 

8 rows in set (0.01 sec) 

mysql> show variables like "%coll%"; 

+----------------------+-------------------+ 

| Variable_name        | Value             | 

+----------------------+-------------------+ 

| collation_connection | latin1_swedish_ci | 

| collation_database   | utf8_bin          | 

| collation_server     | utf8_bin          | 

+----------------------+-------------------+ 

3 rows in set (0.00 sec) 

 

 

有几个latin1的...

 

原来是connection的变量是latin1... 忍不了

 

 

修改sql文件

 

SET collation_connection = utf8_bin;

 

SET character_set_client = utf8;

 

SET character_set_connection = utf8;

 

 

mysql  --socket=/opt/mydata/my3306/my3306.sock -A

 

摘自 sunvince的专栏

bitsCN.com
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Issues
MySQL stops process
From 1970-01-01 08:00:00
0
0
0
Error when installing mysql on linux
From 1970-01-01 08:00:00
0
0
0
phpstudy cannot start mysql?
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template