user
user

Reputation: 631

using MySQL workbench to insert Arabic characters to the MySQL database

iam facing problem incase of inserting and viewing arabic characater to mysql database using MySQLworkbenh ,how i can insert Arabic characters to tables in my database using MySQLworkbenh?and how i can import data from csv file to MySQL via MySQLworkbench? can help me?

and this my cod

ERROR 1366: Incorrect string value: '\xD8\xA7\xD9\x84\xD9\x85...' for column 'name' at row 1

SQL Statement:

UPDATE mydb.exercise SET name='المشي ' WHERE name='walking'

ERROR 1366: Incorrect string value: '\xD8\xA7\xD9\x84\xD8\xB3...' for column 'name' at row 1

SQL Statement:

INSERT INTO mydb.exercise (name, burned_calories) VALUES ('السباحه ', 10)

ERROR 1366: Incorrect string value: '\xD9\x83\xD8\xB1\xD9\x87...' for column 'name' at row 1

SQL Statement:

INSERT INTO mydb.exercise (name, burned_calories) VALUES ('كره القدم', 5)

Upvotes: 3

Views: 4665

Answers (1)

Elvis
Elvis

Reputation: 857

OK here is the problem: in case you made a fresh install of mysql it will probably keep the default character set (letters to insert into columns such as "λσκαι" in greek or "abssmss" in latin) which is latin1.

So when you create a table (either by a ER model or directly from Create Table) in workbench the new table will keep the default character set. In able to change it you can open your table and right click over your table -> Alter Table. In Table tab choose Collation: utf8 default.

There are cases that it doesn't work: you already have a table with columns (column1, column2, etc). In such a case the problem is that every existed column will keep its original character set.

So all you have to do is, go to Columns tab (in the window opened when you choose Alter Table see above) and choose a column ( i.e. column1 ) and in the right panel choose for that column Collation: utf8 default. Do this for each column you might probably have character other than latin.

After finishing click: Alter then Finish and you will be OK. At least this was the problem in my case.

I hope I helped you with this solution. (A friendly suggestion, next time you don't use key words such as Arabic because you wont get any help, well you see no body respond to you even this question is posted since Jan. 7. Instead replace Arabic with Chinese or American Indian or what so ever since... you know the reason, and you will get a respond very quick. E christian friend here!)

Upvotes: 2

Related Questions