user3587265 user3587265 - 5 months ago 17
MySQL Question

MySQL Arabic Character Encoding

I want to insert Arabic data in MySQL database. I tried to change the table encoding to UTF-8 using this command:

ALTER TABLE `t` DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;


I also tried the collation utf8_bin and I changed it in the my-default.ini file (on Windows) but all what I am getting are characters like this: Ï¡┘àϺϻϮ

This is an example of what I am getting:

Value inserted || Value selected || Hex value selected
دددد || ϻϻϻϻ || C38FC2BBC38FC2BBC38FC2BBC38FC2BB
rrr || rrr || 727272


Any suggestions?

Edit: The problem was solved by editing mysql files. See the accepted answer below.

Answer

I finally solved the problem.

After checking where mysqld gets the default options from using the command:

mysqld --help --verbose > temp_file_path

In the temp file, I found that it gets the default options as stated below:

Default options are read from the following files in the given order:
C:\WINDOWS\my.ini C:\WINDOWS\my.cnf C:\my.ini C:\my.cnf C:\Program Files\MySQL\MySQL Server 5.6\my.ini C:\Program Files\MySQL\MySQL Server 5.6\my.cnf

None of these files were found on my machine, so I had to rename the file 'my-default.ini' to 'my.ini'. Adding the correct encoding to the file, the problem was solved.