1:下载并安装Mysql:

1.1在官网下载:

watermark,type_d3F5LXplbmhlaQ,shadow_50,text_Q1NETkDku4rlubTlj4jnp4PlpLTkuoY,size_20,color_FFFFFF,t_70,g_se,x_16

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

watermark,type_d3F5LXplbmhlaQ,shadow_50,text_Q1NETkDku4rlubTlj4jnp4PlpLTkuoY,size_20,color_FFFFFF,t_70,g_se,x_16

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;

watermark,type_d3F5LXplbmhlaQ,shadow_50,text_Q1NETkDku4rlubTlj4jnp4PlpLTkuoY,size_20,color_FFFFFF,t_70,g_se,x_16

#设置权限与密码

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;

watermark,type_d3F5LXplbmhlaQ,shadow_50,text_Q1NETkDku4rlubTlj4jnp4PlpLTkuoY,size_20,color_FFFFFF,t_70,g_se,x_16

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;

watermark,type_d3F5LXplbmhlaQ,shadow_50,text_Q1NETkDku4rlubTlj4jnp4PlpLTkuoY,size_16,color_FFFFFF,t_70,g_se,x_16

 5.3:插入数据

insert into xscj values(null,'李晓龙','女','云计算与大数据处理',76,'2021-07-10');

watermark,type_d3F5LXplbmhlaQ,shadow_50,text_Q1NETkDku4rlubTlj4jnp4PlpLTkuoY,size_20,color_FFFFFF,t_70,g_se,x_16

watermark,type_d3F5LXplbmhlaQ,shadow_50,text_Q1NETkDku4rlubTlj4jnp4PlpLTkuoY,size_20,color_FFFFFF,t_70,g_se,x_16

验证结果:select

 select * from xscj;

watermark,type_d3F5LXplbmhlaQ,shadow_50,text_Q1NETkDku4rlubTlj4jnp4PlpLTkuoY,size_11,color_FFFFFF,t_70,g_se,x_16

5.4:计算平均成绩: 

select AVG(cj) from xscj where km='云计算与大数据处理' and kssj='2021-3-25';

watermark,type_d3F5LXplbmhlaQ,shadow_50,text_Q1NETkDku4rlubTlj4jnp4PlpLTkuoY,size_20,color_FFFFFF,t_70,g_se,x_16

结果符合计算出的平均成绩