8.2 MYSQL

1.下载安装MySQL

https://blog.csdn.net/lsrzhangmin/article/details/132492978?spm=1001.2014.3001.5501

2.解压

[root@15 ~]# tar -xvf mysql-8.0.33-1.el7.x86_64.rpm-bundle.tar

3.解决依赖

[root@15 ~]# rpm -ivh mysql-community-server-8.0.33-1.el7.x86_64.rpm
警告:mysql-community-server-8.0.33-1.el7.x86_64.rpm: 头V4 RSA/SHA256 Signature, 密钥 ID 3a79bd29: NOKEY
错误:依赖检测失败:
    mysql-community-client(x86-64) >= 8.0.11 被 mysql-community-server-8.0.33-1.el7.x86_64 需要
    mysql-community-common(x86-64) = 8.0.33-1.el7 被 mysql-community-server-8.0.33-1.el7.x86_64 需要
    mysql-community-icu-data-files = 8.0.33-1.el7 被 mysql-community-server-8.0.33-1.el7.x86_64 需要
[root@15 ~]# rpm -ivh mysql-community-client-8.0.33-1.el7.x86_64.rpm 
警告:mysql-community-client-8.0.33-1.el7.x86_64.rpm: 头V4 RSA/SHA256 Signature, 密钥 ID 3a79bd29: NOKEY
错误:依赖检测失败:
    mysql-community-client-plugins = 8.0.33-1.el7 被 mysql-community-client-8.0.33-1.el7.x86_64 需要
    mysql-community-libs(x86-64) >= 8.0.11 被 mysql-community-client-8.0.33-1.el7.x86_64 需要
[root@15 ~]# rpm -ivh mysql-community-client-plugins-8.0.33-1.el7.x86_64.rpm 警告:mysql-community-client-plugins-8.0.33-1.el7.x86_64.rpm: 头V4 RSA/SHA256 Signature, 密钥 ID 3a79bd29: NOKEY
准备中...                          ################################# [100%]
正在升级/安装...
   1:mysql-community-client-plugins-8.################################# [100%]
[root@15 ~]# rpm -ivh mysql-community-libs-8.0.33-1.el7.x86_64.rpm 
警告:mysql-community-libs-8.0.33-1.el7.x86_64.rpm: 头V4 RSA/SHA256 Signature, 密钥 ID 3a79bd29: NOKEY
错误:依赖检测失败:
    mysql-community-common(x86-64) >= 8.0.11 被 mysql-community-libs-8.0.33-1.el7.x86_64 需要
[root@15 ~]# rpm -ivh mysql-community-common-8.0.33-1.el7.x86_64.rpm 
警告:mysql-community-common-8.0.33-1.el7.x86_64.rpm: 头V4 RSA/SHA256 Signature, 密钥 ID 3a79bd29: NOKEY
准备中...                          ################################# [100%]
正在升级/安装...
   1:mysql-community-common-8.0.33-1.e################################# [100%]
[root@15 ~]# rpm -ivh mysql-community-libs-8.0.33-1.el7.x86_64.rpm 
警告:mysql-community-libs-8.0.33-1.el7.x86_64.rpm: 头V4 RSA/SHA256 Signature, 密钥 ID 3a79bd29: NOKEY
准备中...                          ################################# [100%]
正在升级/安装...
   1:mysql-community-libs-8.0.33-1.el7################################# [100%]
[root@15 ~]# rpm -ivh mysql-community-client-8.0.33-1.el7.x86_64.rpm 
警告:mysql-community-client-8.0.33-1.el7.x86_64.rpm: 头V4 RSA/SHA256 Signature, 密钥 ID 3a79bd29: NOKEY
准备中...                          ################################# [100%]
正在升级/安装...
   1:mysql-community-client-8.0.33-1.e################################# [100%]
[root@15 ~]# rpm -ivh mysql-community-server-8.0.33-1.el7.x86_64.rpm
警告:mysql-community-server-8.0.33-1.el7.x86_64.rpm: 头V4 RSA/SHA256 Signature, 密钥 ID 3a79bd29: NOKEY
错误:依赖检测失败:
    mysql-community-icu-data-files = 8.0.33-1.el7 被 mysql-community-server-8.0.33-1.el7.x86_64 需要
[root@15 ~]# rpm -ivh mysql-community-icu-data-files-8.0.33-1.el7.x86_64.rpm 警告:mysql-community-icu-data-files-8.0.33-1.el7.x86_64.rpm: 头V4 RSA/SHA256 Signature, 密钥 ID 3a79bd29: NOKEY
准备中...                          ################################# [100%]
正在升级/安装...
   1:mysql-community-icu-data-files-8.################################# [100%]
[root@15 ~]# rpm -ivh mysql-community-server-8.0.33-1.el7.x86_64.rpm
警告:mysql-community-server-8.0.33-1.el7.x86_64.rpm: 头V4 RSA/SHA256 Signature, 密钥 ID 3a79bd29: NOKEY
准备中...                          ################################# [100%]
正在升级/安装...
   1:mysql-community-server-8.0.33-1.e################################# [100%]
[root@15 ~]#  

4.启服务:

[root@15 ~]# systemctl status mysqld.service

5.在/var/log目录下查看初始密码:

[root@15 ~]# cd /var/log/
[root@15 log]# grep -n password mysqld.log
120:2024-08-02T03:11:36.543143Z 6 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: Zj<tEhcG:2mq

6.登录MySQL,更改密码

[root@15 log]# mysql -u root -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 8
Server version: 8.0.33

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.

mysql> ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'Mysql@1234';
Query OK, 0 rows affected (0.04 sec)

7.创建test表:

mysql> create database test charset utf8;

8.查看表:

mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| sys                |
| test               |
+--------------------+
5 rows in set (0.02 sec)


9.进入test表,创建

mysql> use test;
Database changed

mysql> CREATE TABLE `test`.`user` (
    ->   `id` INT NOT NULL AUTO_INCREMENT,
    ->   `username` VARCHAR(45) NOT NULL,
    ->   `password` VARCHAR(45) NOT NULL,
    ->   PRIMARY KEY (`id`),
    ->   UNIQUE INDEX `username_UNIQUE` (`username` ASC) VISIBLE)
    -> COMMENT = 'us';
Query OK, 0 rows affected (0.01 sec)


10.查看表内容:

mysql> desc user;

11.添加表内容:
 

mysql> insert into user values (1,'zhangsan','111')
    -> ;
Query OK, 1 row affected (0.02 sec)
 
mysql> insert into user values (2,'lisi','222');
Query OK, 1 row affected (0.00 sec)
 
mysql> insert into user values (3,'wangwu','333');
Query OK, 1 row affected (0.00 sec)
 
mysql> insert into user values (4,'yulan','444');
Query OK, 1 row affected (0.00 sec)
 
mysql> select * from user;
+----+----------+----------+
| id | username | password |
+----+----------+----------+
|  1 | zhangsan | 111      |
|  2 | lisi     | 222      |
|  3 | wangwu   | 333      |
|  4 | yulan    | 444      |
+----+----------+----------+
4 rows in set (0.00 sec)
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值