0

In My wordpress site ,database(mysql) has been upgraded, previously the table charset was utf8mb4 but now it become utf8 and it will not support utf8mb4. So in my wp-config file I have changed the charset to utf8.

But I am getting error Like this

http error 500

image

lokusking
  • 7,396
  • 13
  • 38
  • 57
aneesh
  • 171
  • 2
  • 2
  • 11

1 Answers1

0

Please use the code for convert your WordPress database.

<?php
error_reporting(E_ALL);
$dbname = "YOUR-DATABASE-NAME";
mysql_connect("localhost", "YOUR-DATABASE-USERNAME", "YOUR-DATABASE-PASSWORD") or die(mysql_error());
mysql_select_db("$dbname");
mysql_query("SET NAMES 'utf8';") or die(mysql_error());

$query = "SHOW TABLES";
$result = mysql_query($query) or die(mysql_error());
while ($data = mysql_fetch_assoc($result)) {

 $table = $data["Tables_in_$dbname"];
 $query = "alter table $table convert to character set utf8 collate utf8_turkish_ci";
 mysql_query($query) or die(mysql_error());
 echo "<b>$table</b><br>";

 $query = "SHOW COLUMNS FROM $table";
 $result_2 = mysql_query($query) or die(mysql_error());
 while ($columns = mysql_fetch_assoc($result_2)) {

  if (
    (stripos($columns['Type'], 'varchar')!==false)
    ||
    (stripos($columns['Type'], 'text')!==false)
  ) {
   $query = "ALTER TABLE $table MODIFY {$columns['Field']} {$columns['Type']} CHARACTER SET utf8 COLLATE utf8_turkish_ci";
   mysql_query($query) or die(mysql_error());
   echo "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{$columns['Field']}<br>";
  }
 }
}

echo "<hr><h1>Done!</h1>";
Rustem Hesenov
  • 429
  • 5
  • 6