第十一周

就业和全程班小伙伴本周学习内容:

二十一、Mysql数据库二

1、MySQL的视图函数存储过程触发器和事件管理(64分钟)

2、MySQL用户和权限管理(40分钟)

3、MySQL架构和存储引擎(51分钟)

4、MySQL的索引结构(61分钟)

5、MySQL索引管理和相关工具(45分钟)

6、MySQL锁管理和事务(44分钟)

7、事务日志管理和错误日志(57分钟)

二十二、Mysql数据库三

1、MySQL的通用日志和慢查询日志及二进制日志(53分钟)

2、MySQL二进制日志管理(53分钟)

3、MySQL备份类型和原理(50分钟)

4、MySQL备份和还原(61分钟)

5、MySQL备份还原实战(56分钟)

6、xtrabackup备份工具实战(61分钟)

7、MYSQL主从复制原理和实现(48分钟)

就业(全程班)第十一周作业:

1、 导入hellodb.sql生成数据库

[root@centos7 ~]#mysql < hellodb_innodb.sql            #方法一

[root@centos7 ~]#source /root/hellodb_innodb.sql       #方法二

MariaDB [(none)]> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| db1 |
| db2 |
| hellodb | #导入成功
| mysql |
| performance_schema |
| student |
| test |
+--------------------+
8 rows in set (0.00 sec)

(1) 在students表中,查询年龄大于25岁,且为男性的同学的名字和年龄

MariaDB [hellodb]> select name,age,gender from students where age >25 and gender ='M';
+--------------+-----+--------+
| name | age | gender |
+--------------+-----+--------+
| Xie Yanke | 53 | M |
| Ding Dian | 32 | M |
| Yu Yutong | 26 | M |
| Shi Qing | 46 | M |
| Tian Boguang | 33 | M |
| Xu Xian | 27 | M |
| Sun Dasheng | 100 | M |
+--------------+-----+--------+
7 rows in set (0.00 sec)

(2) 以ClassID为分组依据,显示每组的平均年龄

MariaDB [hellodb]> select classid,avg(age) from students group by classid;
+---------+----------+
| classid | avg(age) |
+---------+----------+
| NULL | 63.5000 |
| 1 | 20.5000 |
| 2 | 36.0000 |
| 3 | 20.2500 |
| 4 | 24.7500 |
| 5 | 46.0000 |
| 6 | 20.7500 |
| 7 | 19.6667 |
+---------+----------+
8 rows in set (0.00 sec

(3) 显示第2题中平均年龄大于30的分组及平均年龄

MariaDB [hellodb]> select classid,avg(age) from students group by classid having avg(age) >30;
+---------+----------+
| classid | avg(age) |
+---------+----------+
| NULL | 63.5000 |
| 2 | 36.0000 |
| 5 | 46.0000 |
+---------+----------+
3 rows in set (0.00 sec)

(4) 显示以L开头的名字的同学的信息

MariaDB [hellodb]> select * from students where name like 'L%';
+-------+-------------+-----+--------+---------+-----------+
| StuID | Name | Age | Gender | ClassID | TeacherID |
+-------+-------------+-----+--------+---------+-----------+
| 8 | Lin Daiyu | 17 | F | 7 | NULL |
| 14 | Lu Wushuang | 17 | F | 3 | NULL |
| 17 | Lin Chong | 25 | M | 4 | NULL |
+-------+-------------+-----+--------+---------+-----------+
3 rows in set (0.00 sec)

2、数据库授权magedu用户,允许192.168.1.0/24网段可以连接mysql

centos8:
MariaDB [(none)]> source hellodb_innodb.sql
MariaDB [hellodb]> create user magedu@'192.168.1.%' identified by '123456';
MariaDB [(none)]> grant all on hellodb.* to magedu@'192.168.1.%'; [root@centos7 ~]#mysql -umagedu -h192.168.1.8 -p123456
MariaDB [(none)]> show databases;
+--------------------+
| Database |
+--------------------+
| hellodb |
| information_schema |
+--------------------+
2 rows in set (0.00 sec)
MariaDB [(none)]> use hellodb;
MariaDB [hellodb]> show tables;
+-------------------+
| Tables_in_hellodb |
+-------------------+
| classes |
| coc |
| courses |
| scores |
| students |
| teachers |
| toc |
+-------------------+
7 rows in set (0.00 sec) MariaDB [(none)]> select host,user,password from mysql.user;
+--------------------+--------+-------------------------------------------+
| host | user | password |
+--------------------+--------+-------------------------------------------+
| localhost | root | |
| centos8.magedu.org | root | |
| 127.0.0.1 | root | |
| ::1 | root | |
| 10.0.0.% | magedu | *6BB4837EB74329105EE4568DDA7DC67ED2CA2AD9 |
+--------------------+--------+-------------------------------------------+ #查看指定用户获得的授权
MariaDB [(none)]> show grants for magedu@'192.168.1.%';
+-----------------------------------------------------------------------------------------------------------------------+
| Grants for magedu@192.168.1.% |
+-----------------------------------------------------------------------------------------------------------------------+
| GRANT ALL PRIVILEGES ON *.* TO `magedu`@`192.168.1.%` IDENTIFIED BY PASSWORD '*6BB4837EB74329105EE4568DDA7DC67ED2CA2AD9' |
+-----------------------------------------------------------------------------------------------------------------------+
1 row in set (0.00 sec) #取消权限
MariaDB [(none)]> revoke all privileges on hellodb.* from root@'192.168.1.%';
MariaDB [(none)]> show grants for root@'192.168.1.%';
+------------------------------------------------------------------------------------------------------------+
| Grants for root@192.168.1.% |
+------------------------------------------------------------------------------------------------------------+
| GRANT USAGE ON *.* TO `root`@`192.168.1.%` IDENTIFIED BY PASSWORD '*6BB4837EB74329105EE4568DDA7DC67ED2CA2AD9' |
+------------------------------------------------------------------------------------------------------------+

最新文章

  1. git常用的命令集合
  2. javascript中的arguments对象
  3. Linux Unix 环境变量设置实例
  4. Java学习笔记(六)——google java编程风格指南(下)
  5. [转] C# Winform 拦截关闭按钮触发的事件
  6. java学习之常量与进制
  7. 深入分析 Java 中的中文编码问题--转
  8. json的学习笔记
  9. Permutations 好题
  10. python进阶------进程线程(五)
  11. Taro文件上传:Blob Url下载Blob对象本身并通过接口上传到服务器
  12. [转]ORACLE 11G 导出报错(EXP-00003)未找到段 (0,0) 的存储定义
  13. IE无法安装Activex控件
  14. ruby on rails在fedora18上install
  15. EF5.0区别于EF4.0的增删改写法
  16. LeetCode题解之Find the Difference
  17. 回顾一些较简单的dp题
  18. Android-----------广告图片轮播控件
  19. Go语言容器
  20. 如何在两个月的时间内发表一篇EI/SCI论文-我的时间管理心得

热门文章

  1. YMOI 2019.6.15
  2. P1278 单词游戏【题解】(状压dp)
  3. 深入Typescript--03-Typescript中的类(努力加餐饭)
  4. Echarts点击多组数据多个柱子中的一个柱子,获取当前点击的是第几组数据,并获取点击的是当前组别第几根柱子,以及对应横坐标,
  5. react系列-从0开始搭建一个react项目
  6. Grafana 系列文章(三):Tempo-使用 HTTP 推送 Spans
  7. wixtoolset visualstudio 2017打包流程(1)
  8. MyBatis使用四(查询详解)
  9. flex实现圣杯布局
  10. MySQL-字段约束条件