Problem with special char insertion via prompt

2

Dear, I have a table where I make some inserts with data containing special char. I currently use Toad for Mysql, and when I do the insertion by this editor, everything happens correctly, the special chars go up normally, but if I use the source @ script.sql of mysql command line to upload the same data, they do not they climb the special chars, and yes, another char. I would like to know how to get through the prompt in the same way that I upload to Toad.

Table:

DROP TABLE

IF EXISTS DOBER.FINANCEIRO_TRANSPORTADORA;
CREATE TABLE DOBER.FINANCEIRO_TRANSPORTADORA (
    TRANSPK INT (3) NOT NULL AUTO_INCREMENT
    ,CODIGO INT (3) NOT NULL
    ,NATUREZA VARCHAR(16)
    ,NOME VARCHAR(50) NOT NULL
    ,DATA_MODIF DATETIME
    ,USUARIO VARCHAR(10)
    ,PRIMARY KEY (TRANSPK)
    ) DEFAULT CHARACTER SET UTF8 COLLATE utf8_general_ci;

INSERT:

INSERT INTO DOBER.FINANCEIRO_TRANSPORTADORA(
CODIGO,
NATUREZA,
NOME,
DATA_MODIF,
USUARIO) VALUES
(1,'Pessoa Jurídica','TRANSPORTADORA1',NOW(),'Usuario1'),
(2,'Pessoa Jurídica','TRANSPORTADORA2',NOW(),'Usuario2')

    Resultado com o Toad:
1  |  Pessoa Jurídica  |  TRANSPORTADORA1  |  30/10/2014 13:46:51  |  Usuario1
2  |  Pessoa Jurídica  |  TRANSPORTADORA2  |  30/10/2014 13:46:51  |  Usuario2

Resultado com MySqlCommand:
1  |  Pessoa Jurídica  |  TRANSPORTADORA1  |  30/10/2014 13:46:51  |  Usuario1
2  |  Pessoa Jurídica  |  TRANSPORTADORA2  |  30/10/2014 13:46:51  |  Usuario2
    
asked by anonymous 30.10.2014 / 16:52

1 answer

2

The character encoding of your table is UTF-8 .

Your Toad for Mysql editor should be using this same encoding and therefore INSERT works as expected.

Try to save the text file containing the INSERT (this used via the command line) also with the UTF-8 encoding. This should solve the problem.

Using the Notepad ++ text editor you are able to select this encoding.

In addition, it may be necessary to inform the encoding where the file should be interpreted (if the MySql default or the MySql client is not configured for UTF-8). In this case, pass the parameter:

--default-character-set=utf8

See: 4.5.1.1 mysql Options .

    
30.10.2014 / 17:14