使用Redhat操作系统下载MySQL

一、本地下载安装

方法一

①在虚拟机火狐浏览器中搜索MySQL官网(选择第一个下载)

②下载完毕使用xshell远程连接解压及安装

[root@localhost ~]# cd /Downloads/
[root@localhost Downloads]# mkdir /mysql/
[root@localhost Downloads]# mv mysql-8.0.35-1.el9.x86_64.rpm-bundle.tar /mysql/
[root@localhost Downloads]# cd /mysql/
[root@localhost mysql]# tar xvf mv mysql-8.0.35-1.el9.x86_64.rpm-bundle.tar
[root@localhost mysql]# dnf localinstall mysql-community-server-8.0.35-1.el9.x86_64.rpm mysql-community-client-8.0.35-1.el9.x86_64.rpm mysql-community-common-8.0.35-1.el9.x86_64.rpm mysql-community-icu-data-files-8.0.35-1.el9.x86_64.rpm mysql-community-client-plugins-8.0.35-1.el9.x86_64.rpm mysql-community-libs-8.0.35-1.el9.x86_64.rpm
#重启服务
[root@localhost mysql]# systemctl start mysqld
#查看密码
[root@localhost mysql]# grep password /var/log/mysqld.log
2024-01-08T12:51:28.338783Z 6 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: qdug_%:&y2gU
#登录数据库
[root@localhost mysql]# mysql -uroot -p
Enter password:         #此处密码是生成的随机密码
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 10
Server version: 8.0.35

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> show databases;        #查看数据库,测试是否成功
ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.        #错误:必须修改密码才可以
mysql> alter user 'root'@'localhost' identified by '#OPENlab123';        #修改密码
Query OK, 0 rows affected (0.00 sec)

mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| sys                |
+--------------------+
4 rows in set (0.00 sec)
mysql> exit        #退出
Bye

方法二

[root@localhost ~]# wget https://cdn.mysql.com//Downloads/MySQL-8.0/mysql-8.0.35-
1.el9.x86_64.rpm-bundle.tar
[root@localhost ~]# mkdir /mysql/
[root@localhost mysql]# tar xvf mysql-8.0.35-1.el9.x86_64.rpm-bundle.tar
[root@localhost mysql]# dnf localinstall mysql-community-server-8.0.35-1.el9.x86_64.rpm mysql-community-client-8.0.35-1.el9.x86_64.rpm mysql-community-common-8.0.35-1.el9.x86_64.rpm mysql-community-icu-data-files-8.0.35-1.el9.x86_64.rpm mysql-community-client-plugins-8.0.35-1.el9.x86_64.rpm mysql-community-libs-8.0.35-1.el9.x86_64.rpm
#重启服务
[root@localhost mysql]# systemctl start mysqld
#查看密码
[root@localhost mysql]# grep password /var/log/mysqld.log
2024-01-08T12:51:28.338783Z 6 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: qdug_%:&y2gU
#登录数据库
[root@localhost mysql]# mysql -uroot -p
Enter password:         #此处密码是生成的随机密码
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 10
Server version: 8.0.35

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> show databases;        #查看数据库,测试是否成功
ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.        #错误:必须修改密码才可以
mysql> alter user 'root'@'localhost' identified by '#OPENlab123';        #修改密码
Query OK, 0 rows affected (0.00 sec)

mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| sys                |
+--------------------+
4 rows in set (0.00 sec)
mysql> exit        #退出
Bye

二、本地仓库下载安装(本地安装的MySQL默认是没有密码的

①配置本地仓库

[root@localhost ~]# cd /etc/yum.repos.d/
[root@localhost yum.repos.d]# vim /etc/yum.repos.d/wangluo.repo
[wangluo-app]
name=wanluo-app
baseurl=https://mirrors.aliyun.com/centos-stream/9-stream/AppStream/x86_64/os/
gpgcheck=0
[wangluo-base]
name=wangluo-base
baseurl=https://mirrors.aliyun.com/centos-stream/9-stream/BaseOS/x86_64/os/
gpgcheck=0

②下载

[root@localhost yum.repos.d]# mount /dev/sr0 /mnt        #失败可能是没有挂载的原因
#下载(但它的版本不是最新的)
[root@localhost yum.repos.d]# dnf install mysql-server

③测试

[root@localhost yum.repos.d]# systemctl start mysqld
[root@localhost yum.repos.d]# mysql -uroot -p        #不需要密码直接回车
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 9
Server version: 8.0.32 Source distribution

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> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| sys                |
+--------------------+
4 rows in set (0.00 sec)

mysql> exit
Bye

三、网络仓库下载安装

①找仓库文件(双击进去选择第一个下载)

复制下载的链接:https://repo.mysql.com//mysql80-community-release-el9-5.noarch.rpm

②查看本地仓库并下载安装

[root@localhost ~]# cd /etc/yum.repos.d/
[root@localhost yum.repos.d]# vim /rpm.repo
[baseos]
name=baseos
baseurl=/mnt/BaseOS
gpgcheck=0
[appstream]
name=appstream
baseurl=/mnt/AppStream
gpgcheck=0
[root@localhost yum.repos.d]# rpm -i https://repo.mysql.com//mysql80-community-release-el9-5.noarch.rpm
警告:/var/tmp/rpm-tmp.v6x1sA: 头V4 RSA/SHA256 Signature, 密钥 ID 3a79bd29: NOKEY
[root@localhost yum.repos.d]# ll
总用量 16
-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 21:28 redhat.repo
[root@localhost yum.repos.d]# dnf install mysql-server -y

③测试

[root@localhost yum.repos.d]# systemctl start mysqld
[root@localhost yum.repos.d]# systemctl start mysqld
[root@localhost yum.repos.d]#  grep password /var/log/mysqld.log
2024-01-08T13:35:54.233551Z 6 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: eojFkyWh%6Cw
[root@localhost yum.repos.d]# mysql -uroot -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 9
Server version: 8.0.35

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 by '#OPENlab123';
Query OK, 0 rows affected (0.00 sec)

mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| sys                |
+--------------------+
4 rows in set (0.01 sec)

mysql> exit
Bye

四、补充(在命令行界面执行MySQL语句)

①必须要修改环境变量才可使用

环境变量路径为:C:\Program Files\MySQL\MySQL Server 8.0\bin

②在此电脑右键点击属性,打开高级系统设置

③选择环境变量

选中Path之后点击编辑

④点击新建将刚才复制的路径添加进去

⑤测试

  • 8
    点赞
  • 8
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值