Solved

How to insert UTF-8 characters into mysql 5.0 database running on Linux CENT OS

Posted on 2010-09-15
3
672 Views
Last Modified: 2012-06-27
Documentation says utf-8 unicode is the default settings on Linux. Our MySQL server has default server and database character set settings set to UTF-8 Unicode and collation set to utf8-unicode-ci.
Whenever we try to insert records that contain Japanese characters they are displayed as boxes. For example,  trying to insert this  ¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿ in a query shows up as rectangular boxes.
Russian and Polish character are displayed correctly. If the default character set is UTF-8 why isn't MySQL displaying the characters properly? In the knowledge base we see where using a SET statement helped some people. However, that hasn't helped us. Any suggestion will be appreciated.

Thanks
0
Comment
Question by:WPSLNetops
  • 2
3 Comments
 
LVL 5

Expert Comment

by:SaigonJeff
ID: 33692589
Try resetting you table collation to ujis_japanese_ci

Here is a great write up on using Japanese characters in MySQL...
http://mysql2.mirrors-r-us.net/doc/refman/5.0/en/charset-cp932.html

Let us know how it goes.

Good luck.
0
 

Author Comment

by:WPSLNetops
ID: 33726492
Thanks SaigonJeff, but we need our collation to be utf8-unicode-ci.
0
 
LVL 5

Accepted Solution

by:
SaigonJeff earned 500 total points
ID: 33727011
mysql_query("SET NAMES utf8");
mysql_query("SET CHARACTER SET utf8");
mysql_query("SET COLLATION_CONNECTION = 'utf8-unicode-ci'");


Here is an example:

<?php
# FileName="Connection_php_mysql.htm"
# Type="MYSQL"
# HTTP="true"
$hostname = "localhost";
$database = "dbname";
$username = "username";
$password = "password";
$dbname = mysql_pconnect($hostname, $username, $password) or trigger_error(mysql_error(),E_USER_ERROR);

mysql_query("SET NAMES utf8");
mysql_query("SET CHARACTER SET utf8");
mysql_query("SET COLLATION_CONNECTION = 'utf8-unicode-ci'");
?>
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

I still run into .cgi files every now and then. In some instances, I actually prefer the simplicity of a .cgi script to other options. Since I use DreamWeaver extensively, what I needed was a way to open .cgi scripts in Dreamweaver. And I wanted to …
Adobe Dreamweaver CS5 is a WYSIWYG web page editor that has advanced HTML, CSS, and Javascript rendering functionality and is probably the most well-known HTML editor available. Much of Dreamweaver's appeal centers around the Design View interfac…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

911 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now