To modify the character set of a database library table
Data Character Set modification steps
Corresponding to the existing database to modify the character set, cannot be directly through the "ALTER DATABASE character set *"
or "ALTER TABLE tablename Character set *", both commands do not update the existing recorded character set, but only the newly created table or record takes effect.
There is already a record of the character set adjustment, you must want to export the data, modified character set after re-import to complete
Modify the database default encoding
ALTER DATABASE name CharSet character set name
ALTER DATABASE lvnian1 CharSet UTF8;
ALTER DATABASE lvnian1 character set GBK;
########################################
mysql> help ALTER DATABASE;
Name: ' ALTER DATABASE '
Description:
Syntax:
ALTER {DATABASE | SCHEMA} [Db_name]
Alter_specification ...
ALTER {DATABASE | SCHEMA} db_name
UPGRADE DATA DIRECTORY NAME
Alter_specification:
[DEFAULT] CHARACTER SET [=] Charset_name
| [DEFAULT] COLLATE [=] Collation_name
For example:
mysql> CREATE DATABASE Lvnian1;
Query OK, 1 row affected (0.01 sec)
Mysql> Show CREATE Database lvnian1\g;
1. Row ***************************
Database:lvnian1
Create database:create Database ' lvnian1 '/*!40100 DEFAULT CHARACTER SET latin1 */
1 row in Set (0.00 sec)
ERROR:
No query specified
mysql> ALTER DATABASE lvnian1 CharSet UTF8;
Query OK, 1 row Affected (0.00 sec)
Mysql> Show CREATE Database lvnian1\g;
1. Row ***************************
Database:lvnian1
Create database:create Database ' lvnian1 '/*!40100 DEFAULT CHARACTER SET UTF8 */
1 row in Set (0.00 sec)
ERROR:
No query specified
Mysql>
mysql> ALTER DATABASE lvnian1 character set GBK;
Query OK, 1 row Affected (0.00 sec)
Mysql> Show CREATE Database lvnian1\g;
1. Row ***************************
Database:lvnian1
Create database:create Database ' lvnian1 '/*!40100 DEFAULT CHARACTER SET GBK */
1 row in Set (0.00 sec)
ERROR:
No query specified
Mysql>
#####################################################
Summarize a character set that modifies an existing record
For example: Now it is latin1 instead of UTF8
1, build the database and build the statement export, SED batch modified to UTF8
2. Export all data
3. Modify MySQL server and client code to UTF8
4, delete the original library table has data
5. Import new build database already built table statement
6. Import all MySQL data
###########################################################
###########################################################
###########################################################
###########################################################
This article is from the "Struggle Bar" blog, please be sure to keep this source http://lvnian.blog.51cto.com/7155281/1699450
To modify the character set of a database library table