PHWinfo banniere

Titres
PORTAIL ANNUAIRE ARTICLES COMPARATEUR HÉBERGEURS DEVIS FORUMS RÉDUCTEUR D'URL
Précédent   PHWinfo > Autres forums > Forum Programmation & Conception > mysql.general > load data infile and character set
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
load data infile and character set

Réponse
 
LinkBack Outils de la discussion
Vieux 26/10/2007, 14h34   #1
Caleb Racey
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut load data infile and character set

Does anyone know how to get the load data infile command to load utf8 data?

I have setup a database as utf8 with a collation of utf8_general_ci, the
mysqld server is started with --character-set-server=utf8. Server variables
say character_set_database = utf8. I use the sql below

LOAD DATA INFILE 'filename' REPLACE INTO TABLE db.table CHARACTER SET utf8
FIELDS TERMINATED BY '\t' LINES TERMINATED BY '\n'

Yet when i try to load a file with an accented value in it e.g. "Agustín"
the value gets truncated to "Agust"

anyone got any solutions to this?

Regards

Cal

  Réponse avec citation
Vieux 26/10/2007, 15h42   #2
mysql@subtropolix.org
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: load data infile and character set

Caleb Racey wrote:
> Does anyone know how to get the load data infile command to load utf8 data?
>
> I have setup a database as utf8 with a collation of utf8_general_ci, the
> mysqld server is started with --character-set-server=utf8. Server variables
> say character_set_database = utf8. I use the sql below
>
> LOAD DATA INFILE 'filename' REPLACE INTO TABLE db.table CHARACTER SET utf8
> FIELDS TERMINATED BY '\t' LINES TERMINATED BY '\n'
>
> Yet when i try to load a file with an accented value in it e.g. "Agustín"
> the value gets truncated to "Agust"


If you haven't already, issue this first:

SET CHARACTER SET utf8;
SET NAMES utf8;
LOAD DATA INFILE ...

b
  Réponse avec citation
Vieux 26/10/2007, 15h44   #3
Baron Schwartz
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: load data infile and character set

Caleb Racey wrote:
> Does anyone know how to get the load data infile command to load utf8 data?
>
> I have setup a database as utf8 with a collation of utf8_general_ci, the
> mysqld server is started with --character-set-server=utf8. Server variables
> say character_set_database = utf8. I use the sql below
>
> LOAD DATA INFILE 'filename' REPLACE INTO TABLE db.table CHARACTER SET utf8
> FIELDS TERMINATED BY '\t' LINES TERMINATED BY '\n'
>
> Yet when i try to load a file with an accented value in it e.g. "Agustín"
> the value gets truncated to "Agust"
>
> anyone got any solutions to this?


It is indeed buggy and badly documented. It depends on the current
database's character set instead. Try this:

SET NAMES utf8;
SET character_set_database=utf8;
LOAD DATA INFILE...

Baron
  Réponse avec citation
Vieux 26/10/2007, 17h44   #4
Baron Schwartz
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: load data infile and character set

Caleb Racey wrote:
> On 10/26/07, Baron Schwartz <baron@xaprb.com> wrote:
>> Caleb Racey wrote:
>>>> It is indeed buggy and badly documented. It depends on the current
>>>> database's character set instead. Try this:
>>>>
>>>> SET NAMES utf8;
>>>> SET character_set_database=utf8;
>>>> LOAD DATA INFILE...
>>>>
>>>> Baron
>>>>
>>> Thanks for the suggestion
>>>
>>> I'm afraid i get the same behaviour when i try this approach accented

>> values
>>> still truncate at the accent when i use load data infile.
>>>

>> OK, the next suggestion is to use the 'binary' character set. By the
>> way, I accidentally omitted quotes above; I should have typed
>>
>> SET character_set_database='utf8';
>>
>> You should verify your connection's character sets with
>>
>> SHOW VARIABLES LIKE '%character%';
>>
>> Try it with 'binary' and see if that works.
>>
>> Baron

>
> thanks again
> I'm afraid 'binary' achieved the same result as did using utf8 with
> quotes.


I'm out of ideas, then. I wish I could more.

Baron
  Réponse avec citation
Vieux 29/10/2007, 08h26   #5
Dušan Pavlica
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: load data infile and character set

Are you sure your file is coded in utf8? Character set of your file must
be same as charset of your database.

Dusan

Caleb Racey napsal(a):
> Does anyone know how to get the load data infile command to load utf8 data?
>
> I have setup a database as utf8 with a collation of utf8_general_ci, the
> mysqld server is started with --character-set-server=utf8. Server variables
> say character_set_database = utf8. I use the sql below
>
> LOAD DATA INFILE 'filename' REPLACE INTO TABLE db.table CHARACTER SET utf8
> FIELDS TERMINATED BY '\t' LINES TERMINATED BY '\n'
>
> Yet when i try to load a file with an accented value in it e.g. "Agustín"
> the value gets truncated to "Agust"
>
> anyone got any solutions to this?
>
> Regards
>
> Cal
>
>

  Réponse avec citation
Vieux 29/10/2007, 08h31   #6
Ananda Kumar
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: load data infile and character set

Hi,
Try this.

set session collation_database=latin1_swedish_ci;
set session character_set_database=latin1;

regards
anandkl


On 10/29/07, Dušan Pavlica <pavlica@unidataz.cz> wrote:
>
> Are you sure your file is coded in utf8? Character set of your file must
> be same as charset of your database.
>
> Dusan
>
> Caleb Racey napsal(a):
> > Does anyone know how to get the load data infile command to load utf8

> data?
> >
> > I have setup a database as utf8 with a collation of utf8_general_ci,

> the
> > mysqld server is started with --character-set-server=utf8. Server

> variables
> > say character_set_database = utf8. I use the sql below
> >
> > LOAD DATA INFILE 'filename' REPLACE INTO TABLE db.table CHARACTER SET

> utf8
> > FIELDS TERMINATED BY '\t' LINES TERMINATED BY '\n'
> >
> > Yet when i try to load a file with an accented value in it e.g.

> "Agustín"
> > the value gets truncated to "Agust"
> >
> > anyone got any solutions to this?
> >
> > Regards
> >
> > Cal
> >
> >

>
> --
> MySQL General Mailing List
> For list archives: http://lists.mysql.com/mysql
> To unsubscribe: http://lists.mysql.com/mysql?unsub=anandkl@gmail.com
>
>


  Réponse avec citation
Vieux 29/10/2007, 16h01   #7
mysql@subtropolix.org
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: load data infile and character set

Ananda Kumar wrote:
> Hi,
> Try this.
>
> set session collation_database=latin1_swedish_ci;
> set session character_set_database=latin1;
>


Rather:

set session collation_database=utf8_general_ci;
set session character_set_database=utf8;

Also, make sure you have these in my.cnf:

[client]
default-character-set=utf8

[mysqld]
default-character-set=utf8
init-connect='SET NAMES utf8'

And you might want to add these also:

collation_server=utf8_unicode_ci
character_set_server=utf8
  Réponse avec citation
Réponse


Outils de la discussion

Règles de messages
Vous ne pouvez pas créer de nouvelles discussions
Vous ne pouvez pas envoyer des réponses
Vous ne pouvez pas envoyer des pièces jointes
Vous ne pouvez pas modifier vos messages

Les balises BB sont activées : oui
Les smileys sont activés : oui
La balise [IMG] est activée : oui
Le code HTML peut être employé : non
Trackbacks are oui
Pingbacks are oui
Refbacks are oui


Fuseau horaire GMT +1. Il est actuellement 10h04.


Édité par : vBulletin® version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC5 Tous droits réservés.
Version française #16 par l'association vBulletin francophone
PHWinfo est un site Éducation Sans Frontières ©2000-2008
Ad Management by RedTyger
©Tous droits réservés par les parties respectives
Page generated in 0,15026 seconds with 15 queries