load data infile 中文亂碼解決

2021-08-29 17:22:37 字數 1293 閱讀 8418

系統配置linux

mysql 預設utf8

首先使用show variables like "%char%";

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

| variable_name | value

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

| character_set_client | gbk

| character_set_connection | gbk

| character_set_database | utf8

| character_set_filesystem | binary

| character_set_results | gbk

| character_set_server | utf8

| character_set_system | utf8

此時可以使用set names utf8;

再次使用show variables like "%char%";

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

| variable_name | value

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

| character_set_client | utf8

| character_set_connection | utf8

| character_set_database | utf8

| character_set_filesystem | binary

| character_set_results | utf8

| character_set_server | utf8

| character_set_system | utf8

各種字元引數統一為utf8時.

使用mysql -uroot -p -ne "set names utf8;select * from t_kernel where mootime<'2008-10-01 00:00:00'" league >kernel.log

來匯出資料.

匯出完成後,

使用load data infile '/home/mysql/kernel.log' into table t_kernel;

匯入資料.

這次匯入的資料應該正確.

當時顯示可能還是亂碼.你可以通過設定set names gbk;來檢視記錄.是否正常.

load data infile使用詳解

基本語法 load data low priority local infile file name txt replace ignore into table tbl name fields terminated by t optionally enclosed by escaped by lin...

LOAD DATA INFILE使用與詳解

mysql匯入資料一般都是用insert into,那麼mysql有沒有乙個高效匯入方法呢?答案是肯定的,那就是load data infile,下面我們來詳細的講解一下相關的使用方法 基本語法 根據官方的 load data low priority concurrent local infile...

LOAD DATA INFILE字元編碼的問題

quote load data infile c users denny desktop testpage xx.csv into table taobao shop character set utf8 fields terminated by enclosed by escaped by lin...