How do I insert Unicode into a MySQL database?


I'm having trouble transferring Unicode strings from one MySQL database to another using DatabaseLink` functions. Here is my failed attempt to read a string from one database and insert it into another:

SQLSelect[conn["source"], "users", {"user_name"}, SQLColumn["user_id"] == 56]
(* {{"Дмитрий"}} *)

SQLUpdate[conn["target"], "users", {"user_name"}, {%[[1, 1]]}, SQLColumn["user_id"] == 56];

SQLSelect[conn["target"], "users", {"user_name"}, SQLColumn["user_id"] == 56]
(* {{"???????"}} *)

Any ideas on how to do this correctly? Thanks!


Posted 2016-05-16T16:50:15.593

Reputation: 141

Welcome to Mathematica.SE! I suggest the following: 1) As you receive help, try to give it too, by answering questions in your area of expertise. 2) Take the tour! 3) When you see good questions and answers, vote them up by clicking the gray triangles, because the credibility of the system is based on the reputation gained by users sharing their knowledge. Also, please remember to accept the answer, if any, that solves your problem, by clicking the checkmark sign!

– Michael E2 – 2016-05-16T16:58:27.660



Based on this answer, I solved the issue by adding "Properties" -> {"characterEncoding" -> "UTF-8"} to the connection:

conn = OpenSQLConnection[JDBC["mysql", "localhost:3306/test"], 
  "Username" -> user, "Password" -> pwd, 
  "Properties" -> {"characterEncoding" -> "UTF-8"}]


Posted 2016-05-16T16:50:15.593

Reputation: 363