Home >Database >Mysql Tutorial >Mysql modify character set statement
Modify the database character set:
[sql] ALTER DATABASE db_name DEFAULT CHARACTER SET character_name [COLLATE ...];
Change the table's default character set and all character columns (CHAR, VARCHAR, TEXT) to the new character set:
[sql] ALTER TABLE tbl_name CONVERT TO CHARACTER SET character_name [COLLATE ...] 如:ALTER TABLE logtest CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci;
Just modify the table Default character set:
www.2cto.com
[sql]
ALTER TABLE tbl_name DEFAULT CHARACTER SET character_name [COLLATE...]; 如:ALTER TABLE logtest DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;
Modify the character set of the field:
[ sql]
ALTER TABLE tbl_name CHANGE c_name c_name CHARACTER SET character_name [COLLATE ...]; 如:ALTER TABLE logtest CHANGE title title VARCHAR(100) CHARACTER SET utf8 COLLATE utf8_general_ci;
View database encoding:
[sql]
SHOW CREATE DATABASE db_name;
View table encoding:
[sql]
SHOW CREATE TABLE tbl_name;
View field encoding:
[sql]
SHOW FULL COLUMNS FROM tbl_name;
www.2cto.com
After modifying the character set, please restart the Mysql service:
Under Windows:
开始->运行->cmd 停止:net stop mysql 启动:net start mysql
Prerequisite MYSQL has been installed as a windows service
Linux:
1. Startup method
1. Use service to start: service mysqld start
2. Use mysqld script to start: / etc/inint.d/mysqld start
3. Use safe_mysqld to start: safe_mysqld&
2. Stop www.2cto.com
1. Use service to start: service mysqld stop
2. Use mysqld script to start: /etc/inint.d/mysqld stop
3. mysqladmin shutdown
3. Restart
1. Use service to start: service mysqld restart
2. Use mysqld script to start: /etc/inint.d/ mysqld restart
The above is the content of the Mysql character set modification statement. For more related content, please pay attention to the PHP Chinese website (www.php.cn)!