当前位置:网站首页>Ubuntu安装Mysql并查询平均成绩
Ubuntu安装Mysql并查询平均成绩
2022-04-23 06:48:00 【今年又秃头了】
1:下载并安装Mysql:
1.1在官网下载:
1.2解压文件: tar -xvf mysql-server_5.7.13-1ubuntu16.04_i386.deb-bundle.tar
1.3:安装:
libmysqlclient20_5.7.13-1ubuntu16.04_i386.deb
libmysqlclient-dev_5.7.13-1ubuntu16.04_i386.deb
libmysqld-dev_5.7.13-1ubuntu16.04_i386.deb
mysql-common_5.7.13-1ubuntu16.04_i386.deb
mysql-community-source_5.7.13-1ubuntu16.04_i386.deb
mysql-community-client_5.7.13-1ubuntu16.04_i386.deb
mysql-community-server_5.7.13-1ubuntu16.04_i386.deb
mysql-server_5.7.13-1ubuntu16.04_i386.deb
1.4:查询mysql服务状态
service mysql start
1.5:进入mysql
mysql -u root -p
2:初始化配置
sudo mysql_secure_installation
配置项目:
#1
VALIDATE PASSWORD PLUGIN can be used to test passwords...
Press y|Y for Yes, any other key for No: N (选择N ,不会进行密码的强校验)
#2
Please set the password for root here...
New password: (输入密码)
Re-enter new password: (重复输入)
#3
By default, a MySQL installation has an anonymous user,
allowing anyone to log into MySQL without having to have
a user account created for them...
Remove anonymous users? (Press y|Y for Yes, any other key for No) : N (选择N,不删除匿名用户)
#4
Normally, root should only be allowed to connect from
'localhost'. This ensures that someone cannot guess at
the root password from the network...
Disallow root login remotely? (Press y|Y for Yes, any other key for No) : N (选择N,允许root远程连接)
#5
By default, MySQL comes with a database named 'test' that
anyone can access...
Remove test database and access to it? (Press y|Y for Yes, any other key for No) : N (选择N,不删除test数据库)
#6
Reloading the privilege tables will ensure that all changes
made so far will take effect immediately.
Reload privilege tables now? (Press y|Y for Yes, any other key for No) : Y (选择Y,修改权限立即生效)
2.2:检查mysql服务状态:
systemctl status mysql.service
3:配置远程访问:
在Ubuntu下MySQL缺省是只允许本地访问的,使用workbench连接工具是连不上的;
如果你要其他机器也能够访问的话,需要进行配置;
sudo vi /etc/mysql/mysql.conf.d/mysqld.cnf #找到 bind-address 修改值为 0.0.0.0(如果需要远程访问)
sudo /etc/init.d/mysql restart #重启mysql
输入用户密码:
#切换数据库
mysql>use mysql;
#查询用户表命令:
mysql>select User,authentication_string,Host from user;
#查看状态
select host,user,plugin from user;
#设置权限与密码
mysql> ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '密码'; #使用mysql_native_password修改加密规则
mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY '密码' PASSWORD EXPIRE NEVER; #更新一下用户的密码
mysql> UPDATE user SET host = '%' WHERE user = 'root'; #允许远程访问
#刷新cache中配置 刷新权限
mysql>flush privileges;
mysql>quit;
4新建数据库和用户:(步骤介绍)
转换为逻辑数据模型,并检查是否存在逻辑错误,存在错误修改基础数据模型
转换物理数据模型,并导出Sql执行语句,并运行是否可以正常生成表
5:上述操作以及mysql安装完成后,启动Mysql服务器并进入mysql shell界面:
5.1:建立jw数据库
create database jw;
5.2:建立学生成绩的表格 :
use jw;
设计字段列表:学号,姓名,性别,科目,成绩,考试时间
create table xscj (id int(3) auto_increment not null primary key, xm varchar(10),xb varchar(2),km varchar(30),cj int(3),kssj date);
学生成绩表格建立完成后运用describe命令查看表:
describe person;
5.3:插入数据
insert into xscj values(null,'李晓龙','女','云计算与大数据处理',76,'2021-07-10');
验证结果:select
select * from xscj;
5.4:计算平均成绩:
select AVG(cj) from xscj where km='云计算与大数据处理' and kssj='2021-3-25';
结果符合计算出的平均成绩
版权声明
本文为[今年又秃头了]所创,转载请带上原文链接,感谢
https://blog.csdn.net/weixin_48302823/article/details/124247139
边栏推荐
- Ctf-misc summary
- Guoji Beisheng openstack container cloud environment construction
- Internal network security attack and defense: a practical guide to penetration testing (IV): Authority improvement analysis and defense
- 渗透测试面试合集---HVV---
- Implementation of promise all
- Intranet penetration series: dns2tcp of Intranet tunnel
- [极客大挑战 2019]Havefun1
- C read INI file and write data to INI file
- Alibaba sentinel学习QA
- Upload labs range practice
猜你喜欢
Anti shake and throttling
Go语学习笔记 - 结构体 | 从零开始Go语言
内网渗透系列:内网隧道之icmpsh
Chapter VII asset impairment
Redis -- why is the string length of string emstr the upper limit of 44 bytes?
Intranet penetration series: pingtunnel of Intranet tunnel
The displayed amount of ABAP ALV is inconsistent with the exported amount
Research on software security based on NLP (2)
Go语学习笔记 - 异常处理 | 从零开始Go语言
Intranet penetration series: dns2tcp of Intranet tunnel
随机推荐
Buuctf misc brush questions
Research on system and software security (4)
sentinel集成nacos动态更新数据原理
Redis--为什么字符串emstr的字符串长度是44字节上限?
Positioning and decoration style
内网渗透系列:内网隧道之dns2tcp
Chapter VII asset impairment
【无标题】
Flatten arrays
RAID0和RAID5的创建和模拟RAID5工作原理
云计算技能大赛 -- openstack私有云环境 第二部分
C 输出一种二维数组,特点如下。
CSV Column Extract列提取
Upload labs range practice
Intranet penetration series: ICMP of Intranet tunnel_ Tran
数据库之MySQL——基础篇
【编程实践/嵌入式比赛】嵌入式比赛学习记录(二):基于TCP的图片流传输
LeetCode15. 三数之和
访问数据库的时候出现错误 Operation not allowed for a result set of type ResultSet.TYPE_FORWARD_ONLY.详解
1+x云计算中级--脚本搭建读写分离