使用特殊字符在MySQL数据库上插入

时间:2017-10-24 21:59:41

标签: go phpmyadmin centos7

我有以下问题:

我使用Golang制作INSERT INTO,但出于某种原因,它没有正确插入特殊字符(IE:ñ)。

这是SQL句子:

ins, err := db.Prepare("INSERT INTO historico_twitter_instagram( texto_encontrado,
                        busqueda_realizada, id_usuario, link, total_reacciones, 
                        total_negativas, total_positivas, total_neutras, fecha_publicacion,
                        id_red_social,is_falso_positivo,ID_comentario) 
                        VALUES "+ fmt.Sprintf("%s",buscado))

在它正上方我有一个打印在控制台中显示应该插入的内容,它显示了这个:

INSERT INTO historico_twitter_instagram( texto_encontrado, busqueda_realizada,
            id_usuario, link, total_reacciones, total_negativas, total_positivas,
            total_neutras, fecha_publicacion,id_red_social,is_falso_positivo,ID_comentario)
     VALUES ('Test: ñ','@wtonki','999','','1','0','0','1','2017-10-24 00:00:00.0','2','1',
             '922923057840144384')

但是在phpMyAdmin中它替换ñ字符替换其他字符,例如ñ

奇怪的是,如果我手动执行该SQL,它会插入好的。有什么想法吗?

PS:表结构有utf8_general_ci PS2:抱歉我的英语不好! :( PS3:SQL在Go上执行_, err = ins.Run()

0 个答案:

没有答案