Change Database Collation with PHP

02 Oct

This little sql statement can change the collation in your database including tables, columns and everywhere. This is something phpMyAdmin can not handle completely.

Credits goes to original poster.

$conn1=new MySQLi("localhost","root","","exam_db");
    echo mysqli_connect_error();
$res=$conn1->query("show tables") or die($conn1->error);
    $conn1->query("ALTER TABLE $tables[0] CONVERT TO CHARACTER SET utf8 COLLATE utf8_unicode_ci") or die($conn1->error);
echo "The collation of your database has been successfully changed!";


Leave a comment

Posted by on October 2, 2015 in PHP



Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: