Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Mysql character set viewing and setting

2025-02-25 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

The character set problem of MySQL is mainly two concepts, one is Character Sets, the other is Collations, the former is character content and coding, and the latter is some rules for comparing the former. These two parameter sets can be specified at four levels: database instance, single database, table, column, and join.

one。 View MySQL database server

Mysql > show variables like'% char%'

Modify server character set

a. Temporary modification

Mysql > SET character_set_server=utf8

b. Permanent modification

Open / etc/mysql/my.cnf and add character-set-server=utf8 after [mysqld]

Note after modification: service mysql restart

two。 View database character set

Mysql > show variables like'% char%'

Modify database character set

a. Temporary change

Mysql > SET character_set_database=utf8

b. Permanent change

Just change the server level.

3. View the character set of the MySQL data Table (table)

Mysql > show table status from Database like'% countries%'

Modify table level

Mysql > ALTER TABLE table_name DEFAULT CHARSET utf8

four。 View the character set of the MySQL data column (column).

Mysql > show full columns from countries

Modify column

Mysql > ALTER TABLE tablename CHANGE colnum VARCHAR (20) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL

Fifth, change the connection character set

a. Temporary change: mysql > SET character_set_client

b. Permanent change: open / etc/mysql/my.cnf and add default-character-set=utf8 after [client]

Note that restart after modification: service mysql restart

six。 View the character sets supported by the currently installed MySQL.

Mysql > show charset

Mysql > show char set

Permanent change:

Modify my.ini (under windows) or / etc/my.cnf (under linux) through configuration file

Add the following respectively

[mysqld]

Character_server_set=utf8

[mysql]

Default-character-set=utf8

[mysql.server]

Default-character-set=utf8

[mysql_safe]

Default-character-set=utf8

[client]

Default-character-set=utf8

Restart the service: service mysqld restart

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

  • SpringBoot (12): integrated Druid

    First, add dependencies

    © 2024 shulou.com SLNews company. All rights reserved.

    12
    Report