Changing the charset for a MySQL database

Let us say that you have created a MySQL database with the default charset. If you realize that you need to now store non-English characters, say Telugu or Hindi characters into the database, you can change to charset associated with the database to make this happen.

Run the following commands.

ALTER DATABASE <database name> CHARACTER SET utf8 COLLATE utf8_general_ci;
ALTER TABLE <table name> CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;

Leave a Reply

Your email address will not be published. Required fields are marked *