当前位置:网站首页>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
边栏推荐
- Summary of facial classics
- Three minutes to teach you to use Houdini fluid > > to solve particle fluid droplets
- 使用 Ingress 实现金丝雀发布
- SAP tr manual import system operation manual
- Interview learning route
- Quick rehearsal exercise
- Research on system and software security (4)
- Ctf-misc summary
- 惨了,搞坏了领导的机密文件,吐血分享备份文件的代码技巧
- 数据安全问题已成隐患,看vivo如何让“用户数据”重新披甲
猜你喜欢
Ribbon start process
Go语学习笔记 - Slice、Map | 从零开始Go语言
Cloud computing skills competition -- the first part of openstack private cloud environment
Attack and defense world misc questions 1-50
CTF-MISC学习之从开始到放弃
Essays (updated from time to time)
数据库之Mysql——概述安装篇
《内网安全攻防:渗透测试实战指南》读书笔记(五):域内横向移动分析及防御
Construction of middleman environment mitmproxy
Research on software security based on NLP (2)
随机推荐
分布式服务治理Nacos
Complete learning from scratch, machine learning and deep learning, including theory and code implementation, mainly using scikit and mxnet, and some practices (on kaggle)
Intranet penetration series: icmptunnel of Intranet tunnel (Master James Barlow's)
访问数据库的时候出现错误 Operation not allowed for a result set of type ResultSet.TYPE_FORWARD_ONLY.详解
内网渗透系列:内网隧道之icmptunnel(jamesbarlow师傅的)
Go语学习笔记 - 异常处理 | 从零开始Go语言
Principle of sentinel integrating Nacos to update data dynamically
NLLLoss+log_SoftMax=CE_Loss
Search and replacement of C text file (WinForm)
Intranet security attack and defense: a practical guide to penetration testing (6): domain controller security
Intranet penetration series: pingtunnel of Intranet tunnel
CTF-MISC学习之从开始到放弃
智能名片小程序名片详情页功能实现关键代码
Analysis of Nacos source code
Chapter IV intangible assets
Mobile terminal layout (3D conversion, animation)
CTF攻防世界刷题51-
SAP self created table log function is enabled
Face to face summary 2
Implementation of new