首页 > 数据库技术 > 详细

linux 之 mysql 整合

时间:2020-10-05 09:01:32      阅读:35      评论:0      收藏:0      [点我收藏+]

1、安装mariadb并 导入hellodb.sql生成数据库

1.配置yum
技术分享图片
2.安装
yum install mariadb-server
3.查看rpm -ql MariaDB-server | grep service
4.systemctl start mariadb
技术分享图片

5.测试
技术分享图片
技术分享图片
6.安全加固
mysql_secure_installation
7.导入
mysql -uroot -p111111 < hellodb.sql
技术分享图片

(1) 在students表中,查询年龄大于25岁,且为男性的同学的名字和年龄
1.use hellodb
2.select name,age from students where age>25 and gender=‘M‘ ;
技术分享图片

(2) 以ClassID为分组依据,显示每组的平均年龄
select classid,AVG(age) as 平均年龄 from students group by classid
技术分享图片

(3) 显示第2题中平均年龄大于30的分组及平均年龄
select classid,AVG(age) as 平均年龄 from students group by classid having 平均年龄>30
技术分享图片
(4) 显示以L开头的名字的同学的信息
select * from students where name like ‘L%‘
技术分享图片

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

1.use mysql;
2.create user ‘jiapeng‘@‘192.168.111.%‘ identified by ‘123456‘;
3.flush privileges;
技术分享图片
测试,在130客户端进行远程连接
mysql -ujiapeng -p123456 -h 192.168.111.156
技术分享图片
此时发现没有权限,再次进入服务的用户授权
grant all on . to jiapeng@‘192.168.111.%‘ identified by "123456";
再次查看拥有所有的权限
技术分享图片

3、总结mysql常见的存储引擎以及特点。

linux 之 mysql 整合

原文:https://www.cnblogs.com/jiapengchu/p/13768497.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!