Home > Database > Mysql Tutorial > body text

Mysql modify character set statement

黄舟
Release: 2017-01-17 11:38:53
Original
2154 people have browsed it

Modify the database character set:

[sql] 
ALTER DATABASE db_name DEFAULT CHARACTER SET character_name [COLLATE ...];
Copy after login

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;
Copy after login

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;
Copy after login

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;
Copy after login

View database encoding:

[sql]

SHOW CREATE DATABASE db_name;
Copy after login

View table encoding:

[sql]

SHOW CREATE TABLE tbl_name;
Copy after login

View field encoding:

[sql]

SHOW FULL COLUMNS FROM tbl_name;
Copy after login

www.2cto.com

After modifying the character set, please restart the Mysql service:

Under Windows:

开始->运行->cmd
停止:net stop mysql
启动:net start mysql
Copy after login

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)!


Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!