-
-
Save ashokdhaduk/11e64f0dde0f82706c90db54e5708719 to your computer and use it in GitHub Desktop.
Change collation to utf8 of all tables of database
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$dbname=’db’; //your database name | |
$username=’userrname’; // your database user name | |
$password=’password’; //your database user password | |
$db = mysql_connect($dbname,$username,$password); | |
if (!$db) { | |
echo "Cannot connect to the database – incorrect details"; | |
} else { | |
mysql_select_db(‘pm’); | |
$result = mysql_query(‘show tables’); | |
while ($tables = mysql_fetch_array($result)) { | |
foreach ($tables as $key => $value) { | |
mysql_query("ALTER TABLE $value COLLATE utf8_general_ci"); | |
} | |
} | |
echo "The collation of your database has been successfully changed!"; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment