首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >专栏 >MySQL RPM包方式安装教程

MySQL RPM包方式安装教程

原创
作者头像
Power
发布2025-02-28 21:33:20
发布2025-02-28 21:33:20
1K00
代码可运行
举报
运行总次数:0
代码可运行

一、MySQL RPM下载方法

官网地址:https://www.mysql.com/downloads/

步骤一:选择“MySQL Community (GPL) Downloads »”

image.png
image.png

步骤二:选择“MySQL Communtiy Server”

image.png
image.png

步骤三:下载对应操作系统版本的MySQL版本

image.png
image.png

步骤四:这里我们选择基于RedHat和Oracle Linux操作系统的MySQL5.7版本的RPM包

image.png
image.png

二、MySQL RPM安装部署

2.1 MySQL RPM包下载与解压

代码语言:javascript
代码运行次数:0
运行
复制
[root@10-23-223-135 ~]# wget https://cdn.mysql.com/archives/mysql-5.7/mysql-5.7.38-1.el7.x86_64.rpm-bundle.tar 
[root@10-23-223-135 ~]# tar -xvf mysql-5.7.38-1.el7.x86_64.rpm-bundle.tar 
[root@10-23-223-135 ~]# ll
total 1083048
-rw-r--r-- 1 root root  554516480 Mar 23 01:37 mysql-5.7.38-1.el7.x86_64.rpm-bundle.tar
-rw-r--r-- 1 7155 31415  28991900 Mar 23 01:26 mysql-community-client-5.7.38-1.el7.x86_64.rpm
-rw-r--r-- 1 7155 31415    318868 Mar 23 01:26 mysql-community-common-5.7.38-1.el7.x86_64.rpm
-rw-r--r-- 1 7155 31415   4363096 Mar 23 01:26 mysql-community-devel-5.7.38-1.el7.x86_64.rpm
-rw-r--r-- 1 7155 31415  47993516 Mar 23 01:26 mysql-community-embedded-5.7.38-1.el7.x86_64.rpm
-rw-r--r-- 1 7155 31415  23315792 Mar 23 01:26 mysql-community-embedded-compat-5.7.38-1.el7.x86_64.rpm
-rw-r--r-- 1 7155 31415 132675656 Mar 23 01:26 mysql-community-embedded-devel-5.7.38-1.el7.x86_64.rpm
-rw-r--r-- 1 7155 31415   2704332 Mar 23 01:26 mysql-community-libs-5.7.38-1.el7.x86_64.rpm
-rw-r--r-- 1 7155 31415   1264876 Mar 23 01:26 mysql-community-libs-compat-5.7.38-1.el7.x86_64.rpm
-rw-r--r-- 1 7155 31415 186231736 Mar 23 01:27 mysql-community-server-5.7.38-1.el7.x86_64.rpm
-rw-r--r-- 1 7155 31415 126641600 Mar 23 01:27 mysql-community-test-5.7.38-1.el7.x86_64.rpm

2.2 安装前准备工作

代码语言:javascript
代码运行次数:0
运行
复制
# (1) 检查当前系统是否安装过MySQL
[root@10-23-223-135 ~]# rpm -qa |grep -i mysql

#(2) 检查当前系统是否安装过mariadb
[root@10-23-223-135 ~]# rpm -qa |grep -i mariadb
mariadb-libs-5.5.60-1.el7_5.x86_64

# 卸载mariadb
[root@10-23-223-135 ~]# rpm -e mariadb-libs-5.5.60-1.el7_5.x86_64 --nodeps

2.3 安装MySQL RPM包

代码语言:javascript
代码运行次数:0
运行
复制
#(1)安装本地MySQL所有RPM包
[root@10-23-223-135 ~]# yum localinstall -y *.rpm 

#(2)查看MySQL安装时创建的MySQL用户和MySQL组
[root@10-23-223-135 ~]#  cat /etc/passwd |grep mysql
mysql:x:27:27:MySQL Server:/var/lib/mysql:/bin/false

[root@10-23-223-135 ~]# cat /etc/group |grep mysql
mysql:x:27:

[root@10-23-223-135 ~]# mysqladmin --version
mysqladmin  Ver 8.42 Distrib 5.7.38, for Linux on x86_64

#(3)启动MySQL服务
[root@10-23-223-135 ~]# systemctl restart mysqld.service 

[root@10-23-223-135 ~]# ps -ef |grep mysql 
mysql     4312     1  0 17:29 ?        00:00:00 /usr/sbin/mysqld --daemonize --pid-file=/var/run/mysqld/mysqld.pid
root      4364  8512  0 17:31 pts/0    00:00:00 grep --color=auto mysql

2.4 配置MySQL服务器

代码语言:javascript
代码运行次数:0
运行
复制
#(1)查看MySQL密码
[root@10-23-223-135 ~]# grep 'temporary password' /var/log/mysqld.log
2022-08-04T09:29:48.007618Z 1 [Note] A temporary password is generated for root@localhost: y8Q_KX20Megf

#(2)登录MySQL服务器
[root@10-23-223-135 ~]# mysql -uroot -py8Q_KX20Megf
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 3
Server version: 5.7.38

Copyright (c) 2000, 2022, 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>

#(3)首次执行命令,提示必须先修改密码
mysql> show global  variables  like  '%validate_password%';
ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.

# 修改root密码
# MySQL版本5.7.6版本开始的用户可以使用如下命令:
mysql> ALTER USER USER() IDENTIFIED BY 'Admin2022!';
Query OK, 0 rows affected (0.00 sec)

# MySQL版本5.7.6版本以前用户可以使用如下命令:
mysql> SET PASSWORD = PASSWORD('Admin2022!');

原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。

如有侵权,请联系 cloudcommunity@tencent.com 删除。

原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。

如有侵权,请联系 cloudcommunity@tencent.com 删除。

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档