Domanda

I have some accent problem when I execute some sql script in a batch file ( the sql script create the database with tables and some inserts)

That's the batch file that execute the script file:

@echo off

"C:\Program Files\MySQL\MySQL Server 5.1\bin\mysql" -u root -proot < dbase.sql;

That's the problem (he replace the accent) like that:

Ajout chèque entrant

Modifier date encaissement (Chèques Entrants)

instead of that :

Ajout chèque entrant

Modifier date encaissement (Chèques Entrants)

That's what I do for insertions:

-- Insertion des Roles

insert into dbcheques.role(idRole,LibelleRole) values(1,'Ajout chèque entrant');

insert into dbcheques.role(idRole,LibelleRole) values(2,'Chèques entrants à encaisser aujourd\'hui');

insert into dbcheques.role(idRole,LibelleRole) values(3,'Chèques entrants encaissables');

insert into dbcheques.role(idRole,LibelleRole) values(4,'Modifier date encaissement (Chèques Entrants)');

insert into dbcheques.role(idRole,LibelleRole) values(5,'Rechercher un chèque entrant');



insert into dbcheques.role(idRole,LibelleRole) values(6,'Ajout chèque sortant');

insert into dbcheques.role(idRole,LibelleRole) values(7,'Chèques sortants à encaisser aujourd\'hui');

insert into dbcheques.role(idRole,LibelleRole) values(8,'Chèques sortants encaissables');

insert into dbcheques.role(idRole,LibelleRole) values(9,'Modifier date encaissement (Chèques Sortants)');

insert into dbcheques.role(idRole,LibelleRole) values(10,'Rechercher un chèque sortant');


insert into dbcheques.role(idRole,LibelleRole) values(11,'Ajout utilisateur');

insert into dbcheques.role(idRole,LibelleRole) values(12,'Rechercher utilisateur');

insert into dbcheques.role(idRole,LibelleRole) values(13,'Liste des utilisateurs');

insert into dbcheques.role(idRole,LibelleRole) values(14,'Affecter/Retirer un rôle');

insert into dbcheques.role(idRole,LibelleRole) values(15,'Modifier mon profil');
È stato utile?

Soluzione 2

Since you are seeing è instead of è I suppose that your dbase.sql file is encoded as UTF-8 but you don't tell MySQL about it. You'll possibly get the same result if you run your command directly rather than through a .bat file.

The most straightforward way to do so is by adding this on top of the dbase.sql file:

SET NAMES utf8;

To do so, you need to open dbase.sql in a text editor (I suppose you already have one since you are writing a batch script).

Alternatively, you can also call mysql with the --default-character-set parameter:

"C:\Program Files\MySQL\MySQL Server 5.1\bin\mysql" -u root -proot --default-character-set=utf8

Once you get this fixed, I suggest you read and enjoy these two links:

Altri suggerimenti

Add --default-character-set option.

"C:\Program Files\MySQL\MySQL Server 5.1\bin\mysql" --default-character-set=utf8 -u root -proot < dbase.sql;
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top