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

How does the Mysql database view the codes used

2025-03-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)05/31 Report--

This article mainly explains "how to check the code used in Mysql database". Interested friends may wish to have a look at it. The method introduced in this paper is simple, fast and practical. Now let the editor take you to learn "how to view the code used in Mysql database"!

Mysql database default encoding view of the encoding used 1. Use status to view

Mysql > status

-mysql Ver 14.14 Distrib 5.6.44, for Linux (x86: 64) using EditLine wrapperConnection id: 22Current database: Current user: root@localhostSSL: Not in useCurrent pager: stdoutUsing outfile:''Using delimiter:; Server version: 5.6.44 MySQL Community Server (GPL) Protocol version: 10Connection: Localhost via UNIX socketServer characterset: latin1Db characterset: latin1Client characterset: utf8Conn. Characterset: utf8UNIX socket: / var/run/mysqld/mysqld.sockUptime: 6 hours 31 min 31 secThreads: 1 Questions: 905 Slow queries: 1 Opens: 74 Flush tables: 1 Open tables: 67 Queries per second avg: 0.038-

Server characterset: latin1

Db characterset: latin1 (database encoding format)

Client characterset: utf8 (the encoding format in which the client connects)

Conn. Characterset: utf8 (access encoding format)

two。 Use show variables

Show variables like 'character'

Mysql > show variables like 'character%' +-- +-- + | Variable_name | Value | +-- -+ | character_set_client | utf8 | | character_set_connection | utf8 | | character_set_database | latin1 | | character_set_filesystem | binary | | character_set_results | utf8 | | character_set_server | latin1 | | character_set_system | utf8 | | character_sets_dir | / usr/share/mysql/charsets/ | +-- +--

Modify configuration information in / etc/my.cnf file

Use default configuration information

This machine accesses its own database: Server characterset: latin1

Status

Server characterset: latin1Db characterset: latin1Client characterset: utf8Conn. Characterset: utf8

Show variables like 'character%'

+-- +-- + | Variable_name | Value | +-- -+ | character_set_client | utf8 | | character_set_connection | utf8 | | character_set_database | latin1 | | character_set_filesystem | binary | | character_set_results | utf8 | | character_set_server | latin1 | | character_set_system | utf8 | | character_sets_dir | / usr/share/mysql/charsets/ | +-- +--

Create a database encodtest to view its encoding information

Server characterset: latin1Db characterset: latin1Client characterset: utf8Conn. Characterset: utf8mysql > show variables like 'character%' +-- +-- + | Variable_name | Value | +-- -+ | character_set_client | utf8 | | character_set_connection | utf8 | | character_set_database | latin1 | | character_set_filesystem | binary | | character_set_results | utf8 | | character_set_server | latin1 | | character_set_system | utf8 | | character_sets_dir | / usr/share/mysql/charsets/ | +-- +--

Character_set_database is the encoding format of the database

Create a test table to view its default encoding format

Show create table test

+-+-| Table | Create Table | +-- -| test | CREATE TABLE `test` (`id` int (11) NOT NULL PRIMARY KEY (`id`) ENGINE=InnoDB DEFAULT CHARSET=latin1 | +-+--

The default encoding format of DEFAULT CHARSET=latin1 is latin1, which is the same as the database encoding format

Change configuration file / etc/my.cnf

Add settings:

[client] default-character-set = UTF8 [mysqld] character-set-server=utf8collation-server=utf8_unicode_ci

This machine enters the database.

View the encoding format:

Status

Server characterset: utf8Db characterset: utf8Client characterset: utf8Conn. Characterset: utf8

Show variables like 'char%'

+-- +-- + | Variable_name | Value | +-- -+ | character_set_client | utf8 | | character_set_connection | utf8 | | character_set_database | utf8 | | character_set_filesystem | binary | | character_set_results | utf8 | | character_set_server | Utf8 | | character_set_system | utf8 | | character_sets_dir | / usr/share/mysql/charsets/ | +-+-+

Create a database to view its encoding

Same as above

Create a table to view the code:

+-+-- | Table | Create Table | | +-+-- | test | CREATE TABLE `test` (`id` int (11) NOT NULL | PRIMARY KEY (`id`) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci | +

The default encoding format of DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci is the same as the configuration

At this point, I believe you have a deeper understanding of "how to view the code used in the Mysql database". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!

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

Wechat

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

12
Report