0

I have a text file that contains non english word and i need to put it into mysql how can i ?

    203851  ኣብ
    70351   ናይ
    56687   ካብ
    46018   እቲ
    41928   ምስ
    40221   ከም
    38702   ድማ
    29739   ናብ
    28806   እዩ
    23066   ከኣ
    21459   ግን
    21013   እዚ
    20638   ሓደ
Vishal Tarkar
  • 808
  • 11
  • 32
Haben
  • 1
  • See teh solution here https://stackoverflow.com/questions/4957900/loading-utf-8-encoded-text-into-mysql-table You also have to check the connection o set to utf8 – nbk Nov 16 '19 at 09:11
  • Please consider adding some code example of what you have tried and did not manage to achieve so that people can better understand your problem and try to help – giuseppedeponte Nov 16 '19 at 10:04

2 Answers2

0

If by that you mean how can you insert a non-unicode string the answer is: the same way as you would put any other string. Just be careful when you create the column to select an encoding that supports it (for example utf8-mb4 - that means utf8 on 4 bytes, because the default mysql utf8 only uses 3 and... long story here actually :) - should do the trick for mostly anyhting you want to put there).

Then... INSERT INTO tableName (columnName) VALUES ('yourString');

Important note here: You should convert that string to the encoding you use before (again... utf8 would be your best choice). If you don't do that and respect the next paragraph (check below) you are still fine, but if you don't you will end up with messed up stuff.

Just be careful on data processing unfortunately mysql has so many points of failure regarding encoding. It has 1 encoding for db, 1 for table, 1 for column, 1 for data saving, even 1 for the connection so... just try to use the same for all to avoid surprises.

zozo
  • 8,230
  • 19
  • 79
  • 134
  • NO, I don't mean that. what I mean is how can I load the text file into the MySQL database the data is like this. I Already create a database that can hold my non- English words, that is not the problem. the problem is with the loading into the database. Thanks 203851 ኣብ 70351 ናይ 56687 ካብ 46018 እቲ 41928 ምስ 40221 ከም 38702 ድማ 29739 ናብ 28806 እዩ 23066 ከኣ 21459 ግን 21013 እዚ 20638 ሓደ 19855 ነቲ – Haben Nov 16 '19 at 08:42
  • I fail to understand your question then. MySQL is based on relational model (although it evolved a bit lately outside it but that's beside the point). You don't store "data" in "database". You create a table, define a structure then specify each part of data where it should go. If you don't want your data to be treated and stored as a string you should greatly improve the question and provide details on your structure and desired result. The fact that there are non english chars there should make no difference whatsoever to the "loading" process. – zozo Nov 16 '19 at 08:56
0

You have a text file with 2 columns of data? Are they separated by tabs or what?

Use LOAD DATA INFILE with suitable parameters.

Rick James
  • 135,179
  • 13
  • 127
  • 222