随笔分类 -  MySQL

MySQL相关
摘要:1 添加MariaDB yum仓库 vim /etc/yum.repos.d/MariaDB.repo 复制以下到文件 # MariaDB 10.6 CentOS repository list - created 2022-06-20 07:17 UTC # https://mariadb.org 阅读全文
posted @ 2022-06-20 15:15 WaterGe 阅读(493) 评论(0) 推荐(0) 编辑
摘要:1 下载安装包 MySQL :: Download MySQL Community Server 2 解压缩 我解压在E盘根目录 3 配置环境变量MYSQL_HOME 4 配置环境变量PATH 5 管理员运行cmd 6 执行初始化 mysqld --initialize --console 7 安装 阅读全文
posted @ 2022-04-19 10:38 WaterGe 阅读(66) 评论(0) 推荐(0) 编辑
摘要:1 先登陆mysql 2 使用mysql库 3 查询当前用户(可选) 4 修改root用户密码 5 刷新缓存(或直接重启服务器) 阅读全文
posted @ 2019-10-19 16:05 WaterGe 阅读(130) 评论(0) 推荐(0) 编辑
摘要:select ... from 表名 where ... group by ... having ... order by ... limit ...; select ... from A left/right join B on ... where ...; 阅读全文
posted @ 2019-07-28 18:23 WaterGe 阅读(317) 评论(0) 推荐(0) 编辑
摘要:SQL分类 DDL数据定义语言 包括:create alter drop truncate 不支持事务 DML数据操作语言 包括:insert delete update select 支持事务 DQL数据查询语言 包括:select TCL事务控制语言 包括:begin; commit; roll 阅读全文
posted @ 2019-07-28 18:21 WaterGe 阅读(137) 评论(0) 推荐(0) 编辑
摘要:MySQL共有5个约束 1 主键约束 primary key(id) 2 外键约束 3 唯一约束 unique 4 非空约束 not null 5 默认约束 default 其他: auto_increment 值自动增加,通常配合主键约束使用 comment 表字段的注释,创建表时在字段后使用 a 阅读全文
posted @ 2019-07-28 17:27 WaterGe 阅读(315) 评论(0) 推荐(0) 编辑
摘要:外键:用于建立关系的字段称为外键 1对1关系 有AB两张表,A表中一条数据对应B表中一条数据,同时B表中一条数据也对应A表中的一条数据 应用场景:为了提高查询效率,把原有的一张表查分成两张表,如:商品表和商品详情表,用户表和用户信息扩展表 1对多关系 有AB两张表,A表中一条数据对应B表中多条数据, 阅读全文
posted @ 2019-07-28 17:04 WaterGe 阅读(3490) 评论(0) 推荐(1) 编辑
摘要:将数据库查询单独开来是因为使用最多,也是技巧最多,同时面试最容易问的部分 简单查询 select * from table_name; select name,age from table_name; 模糊查询%和_ %表示0个或多个未知字符 _表示单个未知字符 select name,age fr 阅读全文
posted @ 2019-07-28 16:55 WaterGe 阅读(254) 评论(0) 推荐(0) 编辑
摘要:插入数据 insert into table_name values('value1','value2','value3',....); 值的数量和顺序必须要和表字段的数量和顺序保持一致 指定字段插入 insert into table_name(字段1名,字段2名...) values('valu 阅读全文
posted @ 2019-07-28 15:41 WaterGe 阅读(132) 评论(0) 推荐(0) 编辑
摘要:新建一个数据库 create database database_name character set utf8; 创建一个表 create table table_name(字段名 类型...) charset=utf8; 查看当前数据库 show databases; 使用一个数据库 use d 阅读全文
posted @ 2019-07-28 00:53 WaterGe 阅读(278) 评论(0) 推荐(0) 编辑
摘要:执行systemctl start mariadb.service后终端控制台报如下错误: Job for mariadb.service failed because the control process exited with error code. See “systemctl status 阅读全文
posted @ 2019-07-28 00:19 WaterGe 阅读(14219) 评论(0) 推荐(0) 编辑
摘要:进入数据库执行 SET GLOBAL character_set_client=utf8;SET GLOBAL character_set_connection=utf8;SET GLOBAL character_set_database=utf8;SET GLOBAL character_set_ 阅读全文
posted @ 2019-07-28 00:15 WaterGe 阅读(2959) 评论(0) 推荐(0) 编辑
摘要:1 centeos7安装mariadb yum -y install mariadb mariadb-server 2 启动mariadb服务 systemctl start mariadb.service systemctl enable mariadb.service 3 配置 执行mysql_ 阅读全文
posted @ 2019-07-28 00:05 WaterGe 阅读(245) 评论(0) 推荐(0) 编辑

点击右上角即可分享
微信分享提示