Solved

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

Posted on 2010-09-15
3
673 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

Are your AD admin tools letting you down?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

Question has a verified solution.

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

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 Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …

809 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