使用Redhat操作系统下载MySQL
2024-01-08 22:42:02
一、本地下载安装
方法一
①在虚拟机火狐浏览器中搜索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
文章来源:https://blog.csdn.net/2201_75581284/article/details/135465311
本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。 如若内容造成侵权/违法违规/事实不符,请联系我的编程经验分享网邮箱:veading@qq.com进行投诉反馈,一经查实,立即删除!
本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。 如若内容造成侵权/违法违规/事实不符,请联系我的编程经验分享网邮箱:veading@qq.com进行投诉反馈,一经查实,立即删除!