Solution #1 - convert DB tables/columns to utf8mb4_unicode_ci:
1. - A
phpMyAdmin - select database -> Operations -> Collation -> utf8mb4_unicode_ci -> Change all tables collations and Change all tables columns collations -> Go.
1. - B
PHP script - change DB credentials in setConfig() function and run it
PHP Code:
<?php
class Convert {
private $config;
private $dbConn;
private $localWordsList;
public function __construct()
{
$this->setConfig();
if (!$this->getConnection()) {
print "Failed to connect to DB!";
exit();
}
$this->doConvert();
}
private function setConfig()
{
// Change it ...
$this->config['dbUser'] = 'my_stats';
$this->config['dbPass'] = 'P@ssword';
$this->config['dbHost'] = 'localhost';
$this->config['dbName'] = 'my_stats';
}
private function getConnection()
{
$dbConn = new mysqli($this->config['dbHost'], $this->config['dbUser'], $this->config['dbPass'], $this->config['dbName']);
if ($dbConn->connect_errno) {
return false;
}
$this->dbConn = $dbConn;
return true;
}
private function doQuery($query) {
$result = $this->dbConn->query($query);
return $result ?: false;
}
private function getDBTables()
{
$query = "SHOW TABLES";
$result = $this->doQuery($query);
if ($result) {
$finalResult = array();
while($tables = mysqli_fetch_array($result)) {
$finalResult[] = $tables[0];
}
return $finalResult;
}
return false;
}
private function getDBColumns($dbTable)
{
$query = "SHOW COLUMNS FROM $dbTable";
$result = $this->doQuery($query);
if ($result) {
$finalResult = array();
while($columns = mysqli_fetch_array($result)) {
$finalResult[] = $columns[0];
}
return $finalResult;
}
return false;
}
public function doConvert()
{
$tables = $this->getDBTables();
foreach ($tables as $key => $value) {
$query = "ALTER TABLE $value CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;";
if ($this->doQuery($query)) {
echo "[OK] Table " . $value . " converted<br>";
$columns = $this->getDBColumns($value);
echo '------------------------------<br>';
foreach ($columns as $columnKey => $column) {
echo '| '.$column.' |<br>';
}
echo '------------------------------<br>';
} else {
echo "[ERR] ".$value." error<br>";
}
}
}
}
new Convert();
2. Edit these files (utf8mb4)
https://github.com/NomisCZ/hlstatsx-...oped_q=utf8mb4,
https://github.com/NomisCZ/hlstatsx-...c400e3ec30a547
Solution #2 - update HLStatsX daemon and website:
1. Stop daemon
2. Run all migration queries:
https://github.com/NomisCZ/hlstatsx-...sql/migrations
3. Download latest daemon:
https://github.com/NomisCZ/hlstatsx-...master/scripts
4. Replace all daemon files (backup your hlstatsx.conf before)
5. Install Perl packages (1.5. Install Perl packages) -
https://github.com/NomisCZ/hlstatsx-...llation#-linux
6. Prepare GeoIP2 (2.4 Prepare GeoIP2) -
https://github.com/NomisCZ/hlstatsx-...2-installation
7. Download latest web files -
https://github.com/NomisCZ/hlstatsx-...ree/master/web
8. Backup your config.php, upload all files to your webhosting and remove updater folder
9. Go to you stats.domain.com -> Admin -> Tools (right column) -> Reset All DB Collations to UTF8
10. Start daemon and check logs
__________________