MySQL 4.0乱七八糟无法转换为较新的MySQL

MySQL 4.0乱七八糟无法转换为较新的MySQL,mysql,utf-8,character-encoding,hebrew,mysql4,Mysql,Utf 8,Character Encoding,Hebrew,Mysql4,我主持的一个网站仍然运行在带有MySQL 4.0的PHP5.2上。它的文本是希伯来语(在网站上显示得很好),但在DB中,文本显示为包含问号的胡言乱语,但不完全是。它看起来有点像:??§?§???§???§? 我正试图用同一个网站将这个数据库迁移到MySQL 5.x,但到目前为止运气不好。我尝试过使用MYSQL 40兼容模式以及其他兼容模式。我已经确保目标数据库具有与旧数据库相同的希伯来文\u bin排序规则,并且我已经使用了集合名称。问题是,这是一种我还不熟悉的胡言乱语,因此不知道如何将其转换为

我主持的一个网站仍然运行在带有MySQL 4.0的PHP5.2上。它的文本是希伯来语(在网站上显示得很好),但在DB中,文本显示为包含问号的胡言乱语,但不完全是。它看起来有点像:
??§?§???§???§?


我正试图用同一个网站将这个数据库迁移到MySQL 5.x,但到目前为止运气不好。我尝试过使用
MYSQL 40
兼容模式以及其他兼容模式。我已经确保目标数据库具有与旧数据库相同的
希伯来文\u bin
排序规则,并且我已经使用了
集合名称
。问题是,这是一种我还不熟悉的胡言乱语,因此不知道如何将其转换为可读文本。

我在这里没有得到另一个答案,因此别无选择,只能编写一个简单的脚本,通过PHP手动执行迁移过程,而不是通过MySQL转储

这是脚本,有一些明显的修改。请注意,脚本是“脏代码”,它可能不安全,也不是最有效的,但如果您在内部使用它,它应该可以完成任务。请勿在脚本未经进一步修改即可供公众访问的环境中使用

<?php
    $local = mysqli_connect([source server], [source username], [source password], [source DB name]) or die('No local connection');
    mysqli_query($local, "SET NAMES 'hebrew'");

    $remote = mysqli_connect([destination server], [destination  username], [destination password], [destination DB name]) or die('No remote connection');
    mysqli_query($remote, "SET NAMES 'utf8'");

    $table_list = array('table1', 'table2', 'table3'); // you can get a list of tables automatically too if the list is very long

    foreach ($table_list as $table)
    {
        $query_local = "SELECT * FROM `{$table}`";

        $result_local = mysqli_query($local, $query_local) or die('Error in q1: '.mysqli_error($local));

        $delete_remote = mysqli_query($remote, "DELETE FROM `{$table}` WHERE 1") or die('Error deleting table: '.$table); // necessary only if you plan to run it more than once

        $i = 0;
        while ($row_local = mysqli_fetch_assoc($result_local))
        {
            foreach ($row_local as $key => $value)
                $row_local[$key] = mysqli_real_escape_string($remote, $value);

            $query_remote = "INSERT INTO `{$table}` (`".implode('`, `', array_keys($row_local))."`) VALUES ('".implode("', '", $row_local)."')";

            $result_remote = mysqli_query($remote, $query_remote)
                or die('Error in remote q'.$i.' in table '.$table.':<br />&nbsp;&nbsp;'.mysqli_error($remote).'<br />&nbsp;&nbsp;Query: '.$query_remote);

            echo 'Successfully transferred row '.$i.' in table '.$table;
            echo '<br />'.PHP_EOL;

            $i++;
        }
    }
?>