mysql第二次作业

本文详细描述了如何在Linux系统中创建一个名为hero的英雄表,并执行插入数据和查询操作,同时介绍了在系统上安装MySQL数据库的过程。
摘要由CSDN通过智能技术生成

目录

1、创建一个英雄表(hero)

(1)创建英雄表(hero)

(2)插入数据

(3)显示该表中所有的数据

2、博客:Linux系统安装MySQL(使用网络仓库安装)

(1)需在mysql官网找到软件仓库,并安装

(2)查看是否安装完成

(3)安装数据库mysql

(4)重启系统mysql程序

(5)进入mysql程序


1、创建一个英雄表(hero)

主键
name
nickname
address
groups
email
telphone

(1)创建英雄表(hero)

mysql> create table t_hero (name varchar(20) primary key, nickname varchar(20), address varchar(20), groupss varchar(20), email int, teelephone int);
Query OK, 0 rows affected (0.00 sec)

(2)插入数据

mysql> insert into t_hero values("猪八戒","天蓬元帅","天庭","西游记",124,421);
Query OK, 1 row affected (0.00 sec)

mysql> insert into t_hero values("沙悟净","卷帘大将","天庭","西游记",125,521);
Query OK, 1 row affected (0.00 sec)

mysql> insert into t_hero values("唐三藏","唐僧","东土大唐","西游记",126,621);
Query OK, 1 row affected (0.00 sec)

mysql> insert into t_hero values("白龙马","小白龙","东海龙宫","西游记",127,721);
Query OK, 1 row affected (0.01 sec)

mysql> insert into t_hero values("刘备","刘玄德","蜀国","三国演义",128,821);
Query OK, 1 row affected (0.00 sec)

mysql> insert into t_hero values("关羽","关云长","蜀国","三国演义",129,921);
Query OK, 1 row affected (0.00 sec)
....

(3)显示该表中所有的数据

2、博客:Linux系统安装MySQL(使用网络仓库安装)

(1)需在mysql官网找到软件仓库,并安装

https://repo.mysql.com//mysql80-community-release-el9-5.noarch.rpm   —— 网络仓库
rpm -i https://repo.mysql.com//mysql80-community-release-el9-5.noarch.rpm  
通过rpm -i 将网络仓库安装到Linux系统

(2)查看是否安装完成

[root@localhost ~]# cd /etc/yum.repos.d/
[root@localhost yum.repos.d]# 
[root@localhost yum.repos.d]# ll
总用量 20
-rw-r--r--. 1 root root 2129 10月 24 21:13 mysql-community-debuginfo.repo
-rw-r--r--. 1 root root 1910 10月 24 21:13 mysql-community.repo
-rw-r--r--. 1 root root 1989 10月 24 21:13 mysql-community-source.repo
-rw-r--r--. 1 root root  358  1月  8 18:02 redhat.repo
-rw-r--r--. 1 root root  128  1月  8 18:00 rpm.repo

(3)安装数据库mysql

[root@localhost ~] # dnf install mysql-server -y
Updating Subscription Management repositories.
Unable to read consumer identity
This system is not registered with an entitlement server. You can use
subscription-manager to register.
Last metadata expiration check: 5 :09:04 ago on Wed 03 Jan 2024 11 :28:41 AM CST.
Dependencies resolved.
=================================================================================
=====================================
Package Architecture Version
Repository Size
=================================================================================
=====================================
Installing: mysql-community-server x86_64 8 .0.35-1.el9
mysql80-community 49 M
Installing dependencies:
mysql-community-client x86_64 8 .0.35-1.el9
mysql80-community 3 .5 M
mysql-community-client-plugins x86_64 8 .0.35-1.el9
mysql80-community 1 .4 M
mysql-community-common x86_64 8 .0.35-1.el9
mysql80-community 557 k
mysql-community-icu-data-files x86_64 8 .0.35-1.el9
mysql80-community 2 .3 M
mysql-community-libs x86_64 8 .0.35-1.el9
mysql80-community 1 .4 M
Transaction Summary
=================================================================================
=====================================
Install 6 Packages
Total download size: 58 M
Installed size: 334 M
Downloading Packages:
(1/6): mysql-community-common-8.0.35-1.el9.x86_64.rpm
246 kB/s | 557 kB 00 :02
(2/6): mysql-community-client-plugins-8.0.35-1.el9.x86_64.rpm
611 kB/s | 1 .4 MB 00 :02
(3/6): mysql-community-libs-8.0.35-1.el9.x86_64.rpm
2 .5 MB/s | 1 .4 MB 00 :00
(4/6): mysql-community-icu-data-files-8.0.35-1.el9.x86_64.rpm
2 .1 MB/s | 2 .3 MB 00 :01
(5/6): mysql-community-client-8.0.35-1.el9.x86_64.rpm
733 kB/s | 3 .5 MB 00 :04
(6/6): mysql-community-server-8.0.35-1.el9.x86_64.rpm
6 .7 MB/s | 49 MB 00 :07
---------------------------------------------------------------------------------
-------------------------------------
Total
5 .7 MB/s | 58 MB 00 :10
MySQL 8 .0 Community Server
2 .9 MB/s | 3 .1 kB 00 :00
Importing GPG key 0xA8D3785C:
Userid : "MySQL Release Engineering <mysql-build@oss.oracle.com>"
Fingerprint: BCA4 3417 C3B4 85DD 128E C6D4 B7B3 B788 A8D3 785C
From : /etc/pki/rpm-gpg/RPM-GPG-KEY-mysql-2023
Key imported successfully
MySQL 8 .0 Community Server
2 .0 MB/s | 3 .1 kB 00 :00
Importing GPG key 0x3A79BD29:
Userid : "MySQL Release Engineering <mysql-build@oss.oracle.com>"
Fingerprint: 859B E8D7 C586 F538 430B 19C2 467B 942D 3A79 BD29
From : /etc/pki/rpm-gpg/RPM-GPG-KEY-mysql-2022
Key imported successfully
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded. Running transaction
Preparing :
1 /1
Installing : mysql-community-common-8.0.35-1.el9.x86_64
1 /6
Installing : mysql-community-client-plugins-8.0.35-1.el9.x86_64
2 /6
Installing : mysql-community-libs-8.0.35-1.el9.x86_64
3 /6
Running scriptlet: mysql-community-libs-8.0.35-1.el9.x86_64
3 /6
Installing : mysql-community-client-8.0.35-1.el9.x86_64
4 /6
Installing : mysql-community-icu-data-files-8.0.35-1.el9.x86_64
5 /6
Running scriptlet: mysql-community-server-8.0.35-1.el9.x86_64
6 /6
Installing : mysql-community-server-8.0.35-1.el9.x86_64
6 /6
Running scriptlet: mysql-community-server-8.0.35-1.el9.x86_64
6 /6
Verifying : mysql-community-client-8.0.35-1.el9.x86_64
1 /6
Verifying : mysql-community-client-plugins-8.0.35-1.el9.x86_64
2 /6
Verifying : mysql-community-common-8.0.35-1.el9.x86_64
3 /6
Verifying : mysql-community-icu-data-files-8.0.35-1.el9.x86_64
4 /6
Verifying : mysql-community-libs-8.0.35-1.el9.x86_64
5 /6
Verifying : mysql-community-server-8.0.35-1.el9.x86_64
6 /6
Installed products updated.
Installed:
mysql-community-client-8.0.35-1.el9.x86_64 mysql-community-client
plugins-8.0.35-1.el9.x86_64
mysql-community-common-8.0.35-1.el9.x86_64 mysql-community-icu-data
files-8.0.35-1.el9.x86_64
mysql-community-libs-8.0.35-1.el9.x86_64 mysql-community-server-
8.0.35-1.el9.x86_64
Complete!

(4)重启系统mysql程序

[root@localhost ~] # systemctl start mysqld

(5)进入mysql程序

[root@localhost ~]# mysql -uroot -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 11
Server version: 8.0.35 MySQL Community Server - GPL

Copyright (c) 2000, 2023, Oracle and/or its affiliates.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

  • 19
    点赞
  • 24
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

重生的风

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值