MySQL RPM包方式安装教程
一、MySQL RPM下载方法
官网地址:https://www.mysql.com/downloads/
步骤一:选择“MySQL Community (GPL) Downloads »”
步骤二:选择“MySQL Communtiy Server”
步骤三:下载对应操作系统版本的MySQL版本
步骤四:这里我们选择基于RedHat和Oracle Linux操作系统的MySQL5.7版本的RPM包
二、MySQL RPM安装部署
2.1 MySQL RPM包下载与解压
[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 安装前准备工作
# (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包
#(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服务器
#(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!');
作者:UStarGao
链接:https://www.starcto.com/mysql/305.html
来源:STARCTO
著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。
UCloud云平台推荐
随便看看
- 2021-02-03MySQL常用参数
- 2024-09-18Windows DOS格式脚本和Linux Unix格式脚本差异导致的跨平台问题
- 2021-09-27MongoDB数据导入导出工具详解
- 2022-08-04MySQL RPM包方式安装教程
- 2021-07-03MySQL压缩包安装教程-二进制