How to create a database and set the default character set?
To create a database and set the default character set, follow these steps:
- Open the MySQL command line tool or another MySQL client tool (such as phpMyAdmin).
- the name of the database
CREATE DATABASE `database_name` CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
In this command, utf8mb4 is the Unicode character set supported by MySQL, and utf8mb4_unicode_ci is a Unicode collation rule. Other character sets and collation rules can be chosen according to the actual requirements. After executing the command, the database will be created and the default character set will be set to the specified character set.
Note: If you are using MySQL version 8.0 or higher, you can replace the utf8mb4 character set and collation with utf8mb4_0900_ai_ci, a new Unicode collation introduced in MySQL 8.0.