当前位置:网站首页>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
边栏推荐
- 二叉树专题--AcWing 18. 重建二叉树(利用前、中序遍历,构建二叉树)
- spritejs
- Implement custom drawer component in quick application
- 力扣(LeetCode)182. 查找重复的电子邮箱(2022.07.01)
- QT学习日记7——QMainWindow
- Gaode draws lines according to the track
- TIPC messaging3
- Matlab processing of distance measurement of experimental electron microscope
- Complement (Mathematical Simulation
- Xiao Sha's pain (double pointer
猜你喜欢
![[play with FPGA learning 4 in simple terms ----- talk about state machine design]](/img/e0/95f8b8c5116c57455e54ad12372f12.png)
[play with FPGA learning 4 in simple terms ----- talk about state machine design]

Importerror: impossible d'importer le nom « graph» de « graphviz»

TIPC messaging3

PHP tea sales and shopping online store

MTK full dump grab

Uncover the secrets of Huawei application market application statistics

Tick Data and Resampling

How to use ide to automatically sign and debug Hongmeng application

Special topic of binary tree -- acwing 3540 Binary search tree building (use the board to build a binary search tree and output the pre -, middle -, and post sequence traversal)

二叉树专题--AcWing 18. 重建二叉树(利用前、中序遍历,构建二叉树)
随机推荐
spritejs
一.STM32的开发环境,keil5/MDK5.14安装教程(附下载链接)
TIPC Service and Topology Tracking4
从攻击面视角,看信创零信任方案实践
PCL point cloud to depth image
flink二開,實現了個 batch lookup join(附源碼)
The working day of the month is calculated from the 1st day of each month
Luogu p1892 [boi2003] Gang (and search for variant anti set)
【深入浅出玩转FPGA学习5-----复位设计】
TIPC Service and Topology Tracking4
二叉树专题--洛谷 P3884 [JLOI2009]二叉树问题(dfs求二叉树深度 bfs求二叉树宽度 dijkstra求最短路)
二.Stm32f407芯片GPIO编程,寄存器操作,库函数操作和位段操作
Is the account above changtou school safe?
Array splitting (regular thinking
Jinshanyun - 2023 Summer Internship
启牛商学院给的股票账户安全吗?能开户吗?
Logu p3398 hamster looks for sugar (double LCA on the tree to judge whether the two paths in the tree intersect)
III Chip startup and clock system
ImportError: cannot import name ‘Digraph‘ from ‘graphviz‘
Iii. Système de démarrage et d'horloge à puce