本篇内容主要讲解“Mysql数据库怎么查看使用的编码”,感兴趣的朋友不妨来看看。本文介绍的方法操作简单快捷,实用性强。下面就让小编来带大家学习“mysql数据库怎么查看使用的编码”吧!Mysql数据库默认编
本篇内容主要讲解“Mysql数据库怎么查看使用的编码”,感兴趣的朋友不妨来看看。本文介绍的方法操作简单快捷,实用性强。下面就让小编来带大家学习“mysql数据库怎么查看使用的编码”吧!
mysql> status
--------------
mysql Ver 14.14 Distrib 5.6.44, for linux (x86_64) using EditLine wrapper
Connection id: 22
Current database:
Current user: root@localhost
SSL: Not in use
Current pager: stdout
Using outfile: ''
Using delimiter: ;
Server version: 5.6.44 MySQL CommUnity Server (GPL)
Protocol version: 10
Connection: Localhost via UNIX Socket
Server characterset: latin1
Db characterset: latin1
Client characterset: utf8
Conn. characterset: utf8
UNIX socket: /var/run/mysqld/mysqld.sock
Uptime: 6 hours 31 min 31 sec
Threads: 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 (数据库编码格式)
Client characterset: utf8 (客户端连接进来的编码格式)
Conn. characterset: utf8 (接入的编码格式)
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/ |
+--------------------------+----------------------------+
/etc/my.cnf文件中修改配置信息
使用默认的配置信息
本机访问自己的数据库:Server characterset: latin1
status
Server characterset: latin1
Db characterset: latin1
Client characterset: utf8
Conn. 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/ |
+--------------------------+----------------------------+
创建一个数据库encodtest,查看其编码信息
Server characterset: latin1
Db characterset: latin1
Client characterset: utf8
Conn. characterset: utf8
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/ |
+--------------------------+----------------------------+
character_set_database是数据库的编码格式
创建一个test表查看其默认的编码格式
show create table test;
+-------+-------------------------------
| Table | Create Table |
+-------+-------------------------------
| test | CREATE TABLE `test` (
`id` int(11) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 |
+-------+-------------------------------
DEFAULT CHARSET=latin1默认的编码格式是latin1,与数据库编码格式相同
更改配置文件/etc/my.cnf
添加设置:
[client]
default-character-set = utf8
[mysqld]
character-set-server=utf8
collation-server=utf8_unicode_ci
本机进入数据库
查看编码格式:
status
Server characterset: utf8
Db characterset: utf8
Client characterset: utf8
Conn. 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/ |
+--------------------------+----------------------------+
创建数据库查看其编码
与上面相同
创建表查看编码:
+-------+------------------------------------------------------
| Table | Create Table |
+-------+------------------------------------------------------
| test | CREATE TABLE `test` (
`id` int(11) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci |
+-------+-----------------------------------------------------
DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci默认的编码格式与配置相同
到此,相信大家对“Mysql数据库怎么查看使用的编码”有了更深的了解,不妨来实际操作一番吧!这里是编程网网站,更多相关内容可以进入相关频道进行查询,关注我们,继续学习!
--结束END--
本文标题: Mysql数据库怎么查看使用的编码
本文链接: https://lsjlt.com/news/60126.html(转载时请注明来源链接)
有问题或投稿请发送至: 邮箱/279061341@qq.com QQ/279061341
2024-10-23
2024-10-22
2024-10-22
2024-10-22
2024-10-22
2024-10-22
2024-10-22
2024-10-22
2024-10-22
2024-10-22
回答
回答
回答
回答
回答
回答
回答
回答
回答
回答
0