// Fill in your Server, User, Database, Password, and Collation configuration below
$db_server = 'localhost';
$db_user = 'database user';
$db_password = 'password';
$db_name = 'database name';
$char_set = 'new character set';
// Adds the header information
header('Content-type: text/plain');
// Connects to the MySQL database
$connection = mysql_connect($db_server, $db_user, $db_password) or die(mysql_error() );
$db = mysql_select_db($db_name) or die( mysql_error() );
// Runs the SQL query on teh database
$sql = 'SHOW TABLES'; $result = mysql_query($sql) or die( mysql_error() );
// Runs a loop that finds all collations within the database and changes it to the new collation
while ( $row = mysql_fetch_row($result) ) {
$table = mysql_real_escape_string($row[0]);
$sql = "ALTER TABLE $table CONVERT TO CHARACTER SET $char_set COLLATE utf8_general_ci";
mysql_query($sql) or die( mysql_error() );
print "$table changed successfully.n";
}
// Update the Collation of the database itself
$sql = "ALTER DATABASE CHARACTER SET $char_set;";
mysql_query($sql) or die( mysql_error());
print "Database collation has been updated successfully.n";
// close the connection to the database
mysql_close($connection);
?>
Chỉnh lại dòng màu đỏ cho phù hợp
Chúc thành công.
Tags: convert database to utf8_general_ci, convert database to utf8_general_ci, convert database into utf 8, convert latin1 database to utf 8, mysql convert database to utf 8, convert database to utf-8 oracle, phpmyadmin convert database to utf 8, convert mysql database to utf 8 phpmyadmin, converting your mysql database to utf 8 phpmyadmin, convert database to utf 8