MySQL, database encoding is a very important problem, sometimes we need to look at the current database encoding, and even need to modify the database encoding.
The SQL statements that view the current database encoding are:
mysql> Use XXX
Database changed
Mysql> Show variables like ' character_set_database ';
+------------------------+--------+
| variable_name | Value |
+------------------------+--------+
| Character_set_database | Latin1 |
+------------------------+--------+
1 row in Set (0.00 sec)
Above, we first switch to the XXX database below, and then use the SQL statement: Show variables like ' character_set_database '; To view the encoding of the XXX database. The result of the query is Latin1 encoding.
Now, let's modify the code of XXX database and change it to gb2312.
mysql> ALTER DATABASE XXX CHARACTER SET gb2312;
Query OK, 1 row Affected (0.00 sec)
Mysql> Show variables like ' character_set_database ';
+------------------------+--------+
| variable_name | Value |
+------------------------+--------+
| Character_set_database | gb2312 |
+------------------------+--------+
1 row in Set (0.00 sec)
Two things are done here too:
1, using SQL statement: ALTER DATABASE XXX CHARACTER SET gb2312; Set the XXX database encoding to gb2312.
2, again use show variables like ' character_set_database '; To confirm what the current xxx is encoding. After confirmation, the database encoding has been modified to gb2312.
3, of course, most of the cases are modified to UTF-8 encoding
About MySQL view and modify the current database encoding, this article introduces so much, I hope to help you, thank you!
View and change of MySQL database format