当前位置:网站首页>CentOS8之mysql基本用法
CentOS8之mysql基本用法
2022-07-02 09:32:00 【N64-HanYeWei】
1、 导入hellodb.sql生成数据库
前期准备安装mariadb-server
yum -y install mariadb-server
systemctl enable --now mariadb.service



导入数据库和表文件
(1) 在students表中,查询年龄大于25岁,且为男性的同学的名字和年龄

MariaDB [hellodb]> select name students_name,age students_age from students where age>=25 and gender='M';
(2) 以ClassID为分组依据,显示每组的平均年龄

MariaDB [hellodb]> select classid ,avg(age) from students group by classid;
(3) 显示第2题中平均年龄大于30的分组及平均年龄

MariaDB [hellodb]> select classid ,avg(age) 平均年龄 from students group by classid having 平均年龄>30;
(4) 显示以L开头的名字的同学的信息

MariaDB [hellodb]> select * from students where name like 'L%';
2、数据库授权magedu用户,允许192.168.1.0/24网段可以连接mysql
前期准备:




echo 1 > /proc/sys/net/ipv4/ip_forward--------开启路由功能

MariaDB [(none)]> grant all privileges on *.* to 'magedu'@'192.168.1.%' identified by '123456';-----------------创建用户并授权但在mysql-8.0已经取消这个功能

[[email protected] ~]# mysql -umagedu -h10.0.0.6 -p123456
边栏推荐
- 从攻击面视角,看信创零信任方案实践
- The working day of the month is calculated from the 1st day of each month
- 金山云——2023届暑期实习
- TIPC addressing 2
- Special topic of binary tree -- acwing 18 Rebuild the binary tree (construct the binary tree by traversing the front and middle order)
- Luogu p4281 [ahoi2008] emergency gathering / gathering (tree doubling LCA)
- 力扣(LeetCode)182. 查找重复的电子邮箱(2022.07.01)
- 二叉树专题--AcWing 19. 二叉树的下一个节点(找树中节点的后继)
- Special topic of binary tree -- acwing 47 Path with a certain value in binary tree (preorder traversal)
- TIPC introduction 1
猜你喜欢

洛谷 P5536 【XR-3】核心城市(贪心 + 树形 dp 寻找树的中心)

Flink two Open, implement Batch Lookup join (attached source)

tqdm的多行显示与单行显示

二.Stm32f407芯片GPIO编程,寄存器操作,库函数操作和位段操作

Special topic of binary tree -- acwing 19 The next node of the binary tree (find the successor of the node in the tree)
![Binary tree topic -- Luogu p3884 [jloi2009] binary tree problem (DFS for binary tree depth BFS for binary tree width Dijkstra for shortest path)](/img/c2/bb85b681af0f78b380b1d179c7ea49.png)
Binary tree topic -- Luogu p3884 [jloi2009] binary tree problem (DFS for binary tree depth BFS for binary tree width Dijkstra for shortest path)

二叉树专题--AcWing 18. 重建二叉树(利用前、中序遍历,构建二叉树)

Win11 arm system configuration Net core environment variable

Internship report skywalking distributed link tracking?

2022-06-17
随机推荐
ros gazebo相关包的安装
Appgallery connect scenario development practice - image storage and sharing
Jenkins安装
From the perspective of attack surface, see the practice of zero trust scheme of Xinchuang
2022 love analysis · panoramic report of digital manufacturers of state-owned enterprises
ctf 记录
The working day of the month is calculated from the 1st day of each month
flink二開,實現了個 batch lookup join(附源碼)
Special topic of binary tree -- acwing 1589 Building binary search tree
TIPC Cluster5
Mongodb learning and sorting (condition operator, $type operator, limit() method, skip() method and sort() method)
JVM garbage collector
【IDEA】使用插件一键逆向生成代码
[AI application] Hikvision ivms-4200 software installation
在网上开股票账户安全吗?我是新手,还请指导
洛谷 P5536 【XR-3】核心城市(贪心 + 树形 dp 寻找树的中心)
QT学习日记7——QMainWindow
Huawei game failed to initialize init with error code 907135000
K-d tree and octree of PCL
Importerror: impossible d'importer le nom « graph» de « graphviz»