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 xxxdatabase changedmysql> 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)
Here are two things: 1, using SQL statements: ALTER DATABASE XXX CHARACTER SET gb2312; Set the code of XXX database in order 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.
About MySQL view and modify the current database encoding, this article introduces so much, I hope to help you, thank you!
From for notes (Wiz)
MySQL Series: View and modify the encoding of the current database