In general, I solved the problem - I’ll place the deployed solution here; it may be useful to someone else, the fact was that the data were recorded in the default encoding of the connection to the server, namely mysql_query ("SET NAMES 'latin1'");
in the end, I simply exported the database from the host to the local host, and created a duplicate of it with completely cleaned (empty tables) and launched such a script
define('BD_HOST','localhost'); //хост бд define('BD_PASS','password'); //пароль бд define('BD_LOGIN','dante'); //Логин бд define('BD_FROM','coa'); //исходная БД define('BD_IN','coreprot'); //конечная БД $tables = array ( 'bask', 'bonus', 'razdel', 'tovar'); //Массив со всеми таблицами которые надо переписать нормально foreach ($tables as $table) { mysql_connect(BD_HOST,BD_LOGIN,BD_PASS); mysql_select_db(BD_FROM); mysql_query("set names 'latin1'");//тут ставим дефолтную корявую кодировку (Это важно!!!) $query_select_from = "SELECT * FROM $table;"; $result = mysql_query($query_select_from); mysql_close(); //запросили все косячные данные и закрыли соединение mysql_connect(BD_HOST,BD_LOGIN,BD_PASS); mysql_select_db(BD_IN); mysql_query("set names utf8"); //открыли новое соединение, но уже указав нормальную кодировку while ($t = mysql_fetch_assoc($result)) { $values = ''; $f = false; foreach($t as $val) { $p = ($f)?',':''; $f = true; $add = (is_int($val))?"$val":"'$val'"; $values.= "$p $add"; }; $insert_in = "INSERT $table VALUES($values)"; mysql_query($insert_in); //запись прочтенной строки, уже в нормальном соединении }; mysql_close(); //закрываем соединение, что бы открыть его уже для другой таблицы.
};
As a result, the database was overwritten in the normal encoding and everything is fine in pma and on the site, immediately put the normal encoding when connecting, as follows:
mysql_query("SET NAMES 'utf8'"); mysql_query("SET CHARACTER SET 'utf8'"); mysql_query("SET SESSION collation_connection = 'utf8_general_ci'");
and all the profit, the MAIN thing I repeat here is to guess the initial encoding of the connection in which everything was written over the joint