In my previous post, I explained on how to Convert MyISAM to InnoDB. This time I’ll show you on how to change the collation of MySQL database tables. BTW, collation controls the way string values are sorted.
This code is useful if the table collation varied from each other. Example one table has utf8_general_ci collation, while the other has utf8_unicode_ci. It’s a best practice if there is uniformity with the table collation to avoid conflict in your data.
Some of the codes in this article are taken from the internet. I just revised some of it so you will benefit from this code.
Be sure to change the following code attached here to fit your needs.
- $username = "root";
- $password = "";
- $db = "database";
- $host = "localhost";
- $target_charset = "utf8";
- $target_collate = "utf8_general_ci";
Note: Due to the size or complexity of this submission, the author has submitted it as a .zip file to shorten your download time. After downloading it, you will need a program like Winzip to decompress it.
Virus note: All files are scanned once-a-day by SourceCodester.com for viruses, but new viruses come out every day, so no prevention program can catch 100% of them.
FOR YOUR OWN SAFETY, PLEASE:
1. Re-scan downloaded files using your personal virus checker before using it.
2. NEVER, EVER run compiled files (.exe's, .ocx's, .dll's etc.)--only run source code.