Tuesday 4 May 2010

MYSQL Data Base Encoding

Hi there,
Today i will talk about how to deal with Multiple language Data base.
first i will talk how to build it from scratch and second how to modify a working copy of database
NOTES:
- in my case i worked with Arabic encoding so i used utf_general_ci as encoding category BUT if the language isn't supported in utf_general_ci choose the supported collection.
- the default encoding for database latin1_swedish_ci.
- My tools => phpMyAdmin , notepad++

Build From Scratch
1) When creating the DB specify the collection to utf_general_ci.
2) When creating the table specify the collection to utf_general_ci.
3) Now each field in the table you need to make it in Arabic make it's collection utf_general_ci.
4) Finally in application to config the Arabic to work fine use this to you connection string :
-General case:
jdbc:mysql://yourhost/yourDB?autoReconnect=true&useUnicode=true&characterEncoding=UTF-8

second: modify a working copy to work with arabic
in my case the database accept Arabic letters and the encoding was latin so i did the following

1) Dump the Database (with phpMyAdmin)
2) Create .txt file
3) copy the dump and paste into the .txt file AND DON'T SAVE THE FILE
4) change the file encoding ( i used the notepad++ encoding tab encode in UTF-8) and save the file
5) you will find the Arabic letter appered :)
6) change the encoding of the DB & tables & fields as the first section.
7) Empty the table and then copy the insert statement from your dump in the .txt file and paste in the phpMyAdmin insert tab


Done :)

3 comments:

  1. Yehia Shouman5 May 2010 at 01:32

    Pretty educative, thanks. :)

    ReplyDelete
  2. special content thx
    my blog http://echo-www.blogspot.com/

    ReplyDelete
  3. 5 Ways to Make Money From Slots - Work to Make Money Online
    The best way to make money from slots is through an online gambling platform that offers real money online casinos. With งานออนไลน์ this process, 1xbet korean you can get 바카라 사이트

    ReplyDelete