1

I need to change encoding of whole database to UTF8.

I was connect to database like this before:

// MySQL connect information.
$username = "root";
$password = "";
$host = "localhost";
$database = "yac";

// Connect.
$connection = mysql_connect($host, $username, $password)
or die ("It seems this site's database isn't responding.");

mysql_select_db($database)
or 

die ("It seems this site's database isn't responding.");

my database content was stored to database without mysql_query("SET NAMES UTF8"); and data was like this:

باشگاه هوانوردان جوان

now recently I connect to database like this:

$mysql_username = "root";
$mysql_password = "";
$mysql_host = "localhost";
$mysql_database = "tick5";
$connection = mysql_connect($mysql_host, $mysql_username, $mysql_password) or die ("It seems this site's database isn't responding.");
mysql_select_db($mysql_database) or die ("It seems this site's database isn't responding.");
mysql_query("SET NAMES utf8"); 
mysql_query("SET CHARACTER_SET utf8");

and stored data is like this:

عنوان مقاله

since I use mysql_query("SET NAMES UTF8"); before INSERT queries I haven't any problem but now I need my old content and I want to change encoding and fix this.

How to do this?

NOTE : my tables Collation is utf8_unicode_ci

ROMANIA_engineer
  • 54,432
  • 29
  • 203
  • 199
Mohammad Masoudian
  • 3,483
  • 7
  • 27
  • 45
  • That's not really clear enough to recommend anything. Please try to list all available information in more chronological order. You connect to the database how? You insert data in what encoding? The data looks how when you look at it how? You want to change what to what and what is the problem? This is all about details, and the ones you gave are a bit fuzzy. – deceze Jun 03 '13 at 13:06
  • possible duplicate of [UTF-8 all the way through](http://stackoverflow.com/questions/279170/utf-8-all-the-way-through) – fancyPants Jun 03 '13 at 13:23
  • This should do it: http://stackoverflow.com/questions/9304485/how-to-detect-utf-8-characters-in-a-latin1-encoded-column-mysql/ – deceze Jun 03 '13 at 14:00

1 Answers1

0

Try to see if this can help you. http://www.gentoo-wiki.info/TIP_Convert_latin1_to_UTF-8_in_MySQL

If you do not have a running Linux system, you can download an Ubuntu LiveCD and run it directly from the CD. http://www.ubuntu.com/download/desktop

Diblo Dk
  • 585
  • 10
  • 26