当前位置:网站首页>Mysql基础学习Day06
Mysql基础学习Day06
2022-07-19 19:27:00 【TonyLiuys】
Mysql基础学习Day06
一、MySQL字符集
1.默认字符集
①MySQL8.0版本之前,默认字符集为latin1,utf8字符集指向的是utf8mb3。
②在数据库设计的时候往往需要将默认的字符集编码修改为utf8字符集,如果忘记了修改默认的字符集,就会出现乱码问题
③从MySQL8.0开始,数据库的默认编码为utf8mb4,从而避免了上述乱码问题。
2.修改字符集
①修改MySQL5的默认字符集:
vi /etc/my.cnf
在[mysqld]下添加:
character_set_server=utf8
重启MySQL服务:
systemctl restart mysqld
之后再创建新的数据库、新的表,在不指定字符集的情况下,就会使用默认的utf8编码
②修改已有的数据库、表的字符集
虽然修改了MySQL5的默认字符集,但是,之前创建的已有的数据库、表的字符集是不会改变的。
使用如下命令修改数据库字符集:
alter database 数据库名 character set ‘utf8’;
修改表字符集:
alter table 表名 convert to character set ‘utf8’;
二、字符集和比较规则
1.MySQL有4个级别的字符集和比较规则,分别是:
服务器级别(MySQL server 级别)
数据库级别
表级别
列级别
执行:show variables like ‘character%’;
mysql> show variables like ‘character%’;
±-------------------------±-------------------------------+
| Variable_name | Value |
±-------------------------±-------------------------------+
| character_set_client | utf8mb4 |
| character_set_connection | utf8mb4 |
| character_set_database | utf8mb4 |
| character_set_filesystem | binary |
| character_set_results | utf8mb4 |
| character_set_server | utf8mb4 |
| character_set_system | utf8mb3 |
| character_sets_dir | /usr/share/mysql-8.0/charsets/ |
±-------------------------±-------------------------------+
2.utf8与utf8mb4:
3.比较规则
常用操作
4.服务器级别
5.数据库级别
6.表级别
7.列级别
8.请求到响应过程中字符集的变化
三、sql_mode的合理设置
1. 介绍
2.宽松模式、严格模式
明天会更好
边栏推荐
- 【微信小程序】label(86/100)
- 157 million: Shenzhen smart · smart traffic management service application platform project
- ES6——Array对象的方法和扩展、数组的遍历 、string的扩展方法
- Kernel Pwn 入门 (4)
- 1. Figure introduction to machine learning Basics
- 《最伟大的作品》,解密周杰伦新专辑背后的数据密码
- Where is the scan function of mobile browser and what is its function
- 3. Introduction to 3D point cloud foundation - pointnet
- Collection of functions commonly used in vs + QT interface design
- 微信公众号所有文章下载链接获取
猜你喜欢
第六届”蓝帽杯“全国大学生网络安全技能大赛WriteUp
Wechat applet map call (quick learning)
Implement custom log storage by rewriting openfeign client
【无标题】
这 20 道 Redis 经典面试题你还不会,就别去面试了!
[C语言]自定义类型(结构体~枚举~联合体)
Where is the scan function of mobile browser and what is its function
Two methods of selecting objects in CAD frame, AutoCAD -- deleting duplicate line segments
Realization of the authority of the background management system, showing different pages according to the authority
微信小程序map地图调用(速学)
随机推荐
《Reinforcement based mobile robot navigation in dynamic environment》翻译
Sorting: quick sort (randomly select pivot), heap sort, merge sort
LeetCode每日一题(396. Rotate Function)
安全浏览器怎么安装蓝色书签插件?
嵌入式分享合集16
1. Figure introduction to machine learning Basics
Icml2022 tutorial | causal fairness analysis, 68 Pages pdf
pytest+yaml框架环境配置和使用教程
在线会议中人脸面部轮廓图像提取(三)——Dlib库人脸面部轮廓图像特征提取
idea2021安装
【JVM学习01】JVM的内存管理
img加载图片失败展示占位图的onerror事件
How to meet the security needs of various cloud environments in the era of digital economy?
SQL注入基础详解
Where is the scan function of mobile browser and what is its function
5. Complex graph network
博客说明&留言板
接口、压力测试工具入门指南
Local variables used by anonymous inner classes should be decorated with final
JS中闭包的特性及其优缺点