Keep special characters when importing into mysql

2019-01-19 22:52发布

问题:

I have a csv file which contains special characters. However, when I import them into my table they do not import. I have the row that needs to contain special characters setup as utf8_general_ci

However, I am losing the special characters upon phpmyadmin import. For example, the degree symbol is not importing. I viewed my csv file in a text editor and it does contain the special characters.

Please help.

Ok, I figured how to do this. See my answer below.

回答1:

Only needs change the charset in mysql when try to upload the file. In my case works the charset windows-1252



回答2:

Ok,

for anyone who has this same issue trying to keep the exported csv file in utf8 while keeping the special characters do the following.

Open up your file in OpenOffice Calc. When you get ready to save it save it as text csv file. While exporting it will ask you what format to save it as. Save it as UTF8 and presto. It does not convert your special characters like excel does.

Hope that helps someone else.



回答3:

Excel usually outputs CSV as UTF-16, but there are ways to get it to output in UTF-8 as explained here

If you are on Windows you can also use the standard Notepad text editor to convert the file by selecting UTF-8 encoding in the Save As dialog as shown below:



回答4:

Try to convert the charset of your csv file to utf8. For exemple with Notepad++

Encoding -> Convert to UTF-8 without BOM


回答5:

Maybe you must check setup as csv file. I think you problem begin in this file. Check this and make sure that both coding were the same(csv and sql table)



标签: mysql csv import