本文共 1674 字,大约阅读时间需要 5 分钟。
查看数据库所有属性编码格式:
mysql> show variables like 'character%';
+--------------------------+-------------------------------+
| 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 | D:\soft\mysql\share\charsets\ |
+--------------------------+-------------------------------+
查看数据库编码格式
mysql> show create database test;
+----------+---------------------------------------------------------------+
| Database | Create Database |
+----------+---------------------------------------------------------------+
| test | CREATE DATABASE `test` /*!40100 DEFAULT CHARACTER SET utf8 */ |
+----------+---------------------------------------------------------------+
查看表编码格式
mysql> show create table user;
+-------+------------------------------------
| Table | Create Table
+-------+------------------------------------
| user | CREATE TABLE `user` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(32) NOT NULL,
`age` int(11) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 |
+-------+------------------------------------
创建数据库时指定编码格式
mysql> create database charset utf8;
Query OK, 1 row affected (0.01 sec)
修改单个数据库的编码格式
mysql> alter database myblog character set utf8;
Query OK, 1 row affected (0.00 sec)
修改数据库默认编码
mysql> set character_set_database=utf8;
Query OK, 0 rows affected (0.00 sec)
---------------------
原文:https://blog.csdn.net/weixin_44278512/article/details/86366192