To convert the existing DB from euc-kr to utf8, after carefully (??) backing it up,
I opened it in editplus, and it says it contains characters that may be lost in the current encoding,
I ignored it, changed it to UTF8, and imported …. Damn ㅠㅠ It won’t work because of the corrupted characters
I searched frantically~~~~ but couldn’t find a solution in the end..
(What do you do in cases like this, where it still doesn’t work even after specifying all the options, including —default-character-set, when dumping? ㅠㅠ)
With no other choice, I found the source below and modified it to suit my needs (UTF8 conversion, selecting the tables I wanted)
Migration confirmed!!!! — Migrating is as annoying and tiring as ever ㅠㅠ
[PHP]
$mysql_host = '********';
$mysql_db = '********';
$mysql_user = '********';
$mysql_pass = '********';
$fileName = 'db-backup';
$extention = "sql";
// Only the tables we need~
$select[] = 'g4_board';
$select[] = 'g4_board_file';
$select[] = 'g4_board_good';
$select[] = 'g4_board_new';
$select[] = 'g4_config';
$select[] = 'g4_group';
$select[] = 'g4_group_member';
$select[] = 'g4_write_cast';
$select[] = 'g4_write_delphibbs';
$select[] = 'g4_write_english';
$select[] = 'g4_write_girl';
$select[] = 'g4_write_gy';
$select[] = 'g4_write_humor';
$select[] = 'g4_write_module';
$select[] = 'g4_write_mypage';
$select[] = 'g4_write_notice';
$select[] = 'g4_write_poll';
$select[] = 'g4_write_qna';
$select[] = 'g4_write_skin';
$select[] = 'g4_write_talk';
$select[] = 'g4_write_temp';
$select[] = 'g4_write_temppds';
$select[] = 'g4_write_test';
$select[] = 'g4_write_tiptech';
$select[] = 'g4_write_varios';
$all = false; // Set to true to generate complete INSERT statements
$drop = true; // Set to true to include DROP TABLE statements
mysql_connect( $mysql_host, $mysql_user, $mysql_pass ) || die("Failed to connect to the database.");
mysql_select_db( $mysql_db ) || die("Failed to connect to the DB");
function bak_getTableNames($db)
{
$result[0] = mysql_list_tables($db);
$result[1] = mysql_num_rows($result[0]);
return $result;
}
function bak_getFields($table)
{
global $all;
$result = mysql_query("show fields from $table");
$i = 0;
while($keys = mysql_fetch_array($result))
{
if(!$i) $defaultOrder = $keys[Field];
if($keys[Key] == 'PRI')
{
$orderby = $keys[Field];
break;
}
$i++;
}
if(!$orderby) $orderby = $defaultOrder;
$result = mysql_query("select * from $table order by $orderby");
$nums = mysql_num_fields($result);
if($all == true)
{
for($i=0;$i<$nums;$i++)
{
$fields[] = mysql_field_name($result,$i);
}
$fields = "(".implode(",",$fields).") ";
}
while($rows = mysql_fetch_row($result))
{
for($i=0;$i<$nums;$i++)
{
$temp = $rows[$i];
$temp = str_replace("'","''", $temp);
$temp = str_replace("","\", $temp);
$temp = str_replace("n",'n', $temp);
$temp = str_replace("r",'r', $temp);
$temp = iconv('CP949', 'UTF-8', $temp);
$insertValues[$i] = $temp;
}
$return .= "INSERT INTO $table ".$fields."values ('".implode("','",$insertValues)."');n";
}
return $return;
}
$tables = bak_getTableNames($mysql_db);
if($tables[1] > 0)
{
$backText = »
# MysqlDump
# Host: «.$mysql_host.»
# Processed at: «.date(‘Y-m-d H:i’).»
# Server version: «.mysql_get_server_info().»
# Database: `».$mysql_db.»`
# ———————————————————nnnnn»;
while($rows = mysql_fetch_row($tables[0]))
{
$chk = false;
for($i=0;$i
[/PHP]




