centos7安装mysql-5.7.18-1.el7.x86_64.rpm-bundle.tar

本文介绍如何在Linux环境下安装MySQL 5.7,并解决安装过程中遇到的冲突问题,包括启动MySQL服务、查看初始密码、登录及重置密码、授权远程连接等步骤。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

1、解压 mysql-5.7.18-1.el7.x86_64.rpm-bundle.tar
tar -xvf mysql-5.7.18-1.el7.x86_64.rpm-bundle.tar

2.解压出来得到一堆rpm

-rw-r--r-- 1 7155 31415  25079412 Mar 20  2017 mysql-community-client-5.7.18-1.el7.x86_64.rpm
-rw-r--r-- 1 7155 31415    277784 Mar 20  2017 mysql-community-common-5.7.18-1.el7.x86_64.rpm
-rw-r--r-- 1 7155 31415   3777808 Mar 20  2017 mysql-community-devel-5.7.18-1.el7.x86_64.rpm
-rw-r--r-- 1 7155 31415  45493312 Mar 20  2017 mysql-community-embedded-5.7.18-1.el7.x86_64.rpm
-rw-r--r-- 1 7155 31415  23924496 Mar 20  2017 mysql-community-embedded-compat-5.7.18-1.el7.x86_64.rpm
-rw-r--r-- 1 7155 31415 126060264 Mar 20  2017 mysql-community-embedded-devel-5.7.18-1.el7.x86_64.rpm
-rw-r--r-- 1 7155 31415   2237888 Mar 20  2017 mysql-community-libs-5.7.18-1.el7.x86_64.rpm
-rw-r--r-- 1 7155 31415   2113196 Mar 20  2017 mysql-community-libs-compat-5.7.18-1.el7.x86_64.rpm
-rw-r--r-- 1 7155 31415  54661812 Mar 20  2017 mysql-community-minimal-debuginfo-5.7.18-1.el7.x86_64.rpm
-rw-r--r-- 1 7155 31415 169622200 Mar 20  2017 mysql-community-server-5.7.18-1.el7.x86_64.rpm
-rw-r--r-- 1 7155 31415  14501488 Mar 20  2017 mysql-community-server-minimal-5.7.18-1.el7.x86_64.rpm
-rw-r--r-- 1 7155 31415 116887988 Mar 20  2017 mysql-community-test-5.7.18-1.el7.x86_64.rpm
3、按顺序安装,先安装
 rpm -ivh  mysql-community-common-5.7.18-1.el7.x86_64.rpm

可能会抛:

warning: mysql-community-common-5.7.18-1.el7.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
Preparing...                          ################################# [100%]
        file /usr/share/mysql/czech/errmsg.sys from install of mysql-community-common-5.7.18-1.el7.x86_64 conflicts with file from package mariadb-libs-1:5.5.44-2.el7.centos.x86_64
        file /usr/share/mysql/danish/errmsg.sys from install of mysql-community-common-5.7.18-1.el7.x86_64 conflicts with file from package mariadb-libs-1:5.5.44-2.el7.centos.x86_64
        file /usr/share/mysql/dutch/errmsg.sys from install of mysql-community-common-5.7.18-1.el7.x86_64 conflicts with file from package mariadb-libs-1:5.5.44-2.el7.centos.x86_64
        file /usr/share/mysql/english/errmsg.sys from install of mysql-community-common-5.7.18-1.el7.x86_64 conflicts with file from package mariadb-libs-1:5.5.44-2.el7.centos.x86_64
        file /usr/share/mysql/estonian/errmsg.sys from install of mysql-community-common-5.7.18-1.el7.x86_64 conflicts with file from package mariadb-libs-1:5.5.44-2.el7.centos.x86_64
        file /usr/share/mysql/french/errmsg.sys from install of mysql-community-common-5.7.18-1.el7.x86_64 conflicts with file from package mariadb-libs-1:5.5.44-2.el7.centos.x86_64
        file /usr/share/mysql/german/errmsg.sys from install of mysql-community-common-5.7.18-1.el7.x86_64 conflicts with file from package mariadb-libs-1:5.5.44-2.el7.centos.x86_64
        file /usr/share/mysql/greek/errmsg.sys from install of mysql-community-common-5.7.18-1.el7.x86_64 conflicts with file from package mariadb-libs-1:5.5.44-2.el7.centos.x86_64
        file /usr/share/mysql/hungarian/errmsg.sys from install of mysql-community-common-5.7.18-1.el7.x86_64 conflicts with file from package mariadb-libs-1:5.5.44-2.el7.centos.x86_64
        file /usr/share/mysql/italian/errmsg.sys from install of mysql-community-common-5.7.18-1.el7.x86_64 conflicts with file from package mariadb-libs-1:5.5.44-2.el7.centos.x86_64
        file /usr/share/mysql/japanese/errmsg.sys from install of mysql-community-common-5.7.18-1.el7.x86_64 conflicts with file from package mariadb-libs-1:5.5.44-2.el7.centos.x86_64
        file /usr/share/mysql/korean/errmsg.sys from install of mysql-community-common-5.7.18-1.el7.x86_64 conflicts with file from package mariadb-libs-1:5.5.44-2.el7.centos.x86_64
        file /usr/share/mysql/norwegian-ny/errmsg.sys from install of mysql-community-common-5.7.18-1.el7.x86_64 conflicts with file from package mariadb-libs-1:5.5.44-2.el7.centos.x86_64
        file /usr/share/mysql/norwegian/errmsg.sys from install of mysql-community-common-5.7.18-1.el7.x86_64 conflicts with file from package mariadb-libs-1:5.5.44-2.el7.centos.x86_64
        file /usr/share/mysql/polish/errmsg.sys from install of mysql-community-common-5.7.18-1.el7.x86_64 conflicts with file from package mariadb-libs-1:5.5.44-2.el7.centos.x86_64
        file /usr/share/mysql/portuguese/errmsg.sys from install of mysql-community-common-5.7.18-1.el7.x86_64 conflicts with file from package mariadb-libs-1:5.5.44-2.el7.centos.x86_64
        file /usr/share/mysql/romanian/errmsg.sys from install of mysql-community-common-5.7.18-1.el7.x86_64 conflicts with file from package mariadb-libs-1:5.5.44-2.el7.centos.x86_64
        file /usr/share/mysql/russian/errmsg.sys from install of mysql-community-common-5.7.18-1.el7.x86_64 conflicts with file from package mariadb-libs-1:5.5.44-2.el7.centos.x86_64
        file /usr/share/mysql/serbian/errmsg.sys from install of mysql-community-common-5.7.18-1.el7.x86_64 conflicts with file from package mariadb-libs-1:5.5.44-2.el7.centos.x86_64
        file /usr/share/mysql/slovak/errmsg.sys from install of mysql-community-common-5.7.18-1.el7.x86_64 conflicts with file from package mariadb-libs-1:5.5.44-2.el7.centos.x86_64
        file /usr/share/mysql/spanish/errmsg.sys from install of mysql-community-common-5.7.18-1.el7.x86_64 conflicts with file from package mariadb-libs-1:5.5.44-2.el7.centos.x86_64
        file /usr/share/mysql/swedish/errmsg.sys from install of mysql-community-common-5.7.18-1.el7.x86_64 conflicts with file from package mariadb-libs-1:5.5.44-2.el7.centos.x86_64
        file /usr/share/mysql/ukrainian/errmsg.sys from install of mysql-community-common-5.7.18-1.el7.x86_64 conflicts with file from package mariadb-libs-1:5.5.44-2.el7.centos.x86_64
        file /usr/share/mysql/charsets/Index.xml from install of mysql-community-common-5.7.18-1.el7.x86_64 conflicts with file from package mariadb-libs-1:5.5.44-2.el7.centos.x86_64
        file /usr/share/mysql/charsets/armscii8.xml from install of mysql-community-common-5.7.18-1.el7.x86_64 conflicts with file from package mariadb-libs-1:5.5.44-2.el7.centos.x86_64
        file /usr/share/mysql/charsets/ascii.xml from install of mysql-community-common-5.7.18-1.el7.x86_64 conflicts with file from package mariadb-libs-1:5.5.44-2.el7.centos.x86_64
        file /usr/share/mysql/charsets/cp1250.xml from install of mysql-community-common-5.7.18-1.el7.x86_64 conflicts with file from package mariadb-libs-1:5.5.44-2.el7.centos.x86_64
        file /usr/share/mysql/charsets/cp1256.xml from install of mysql-community-common-5.7.18-1.el7.x86_64 conflicts with file from package mariadb-libs-1:5.5.44-2.el7.centos.x86_64
        file /usr/share/mysql/charsets/cp1257.xml from install of mysql-community-common-5.7.18-1.el7.x86_64 conflicts with file from package mariadb-libs-1:5.5.44-2.el7.centos.x86_64
        file /usr/share/mysql/charsets/cp850.xml from install of mysql-community-common-5.7.18-1.el7.x86_64 conflicts with file from package mariadb-libs-1:5.5.44-2.el7.centos.x86_64
        file /usr/share/mysql/charsets/cp852.xml from install of mysql-community-common-5.7.18-1.el7.x86_64 conflicts with file from package mariadb-libs-1:5.5.44-2.el7.centos.x86_64
        file /usr/share/mysql/charsets/cp866.xml from install of mysql-community-common-5.7.18-1.el7.x86_64 conflicts with file from package mariadb-libs-1:5.5.44-2.el7.centos.x86_64
        file /usr/share/mysql/charsets/dec8.xml from install of mysql-community-common-5.7.18-1.el7.x86_64 conflicts with file from package mariadb-libs-1:5.5.44-2.el7.centos.x86_64
        file /usr/share/mysql/charsets/geostd8.xml from install of mysql-community-common-5.7.18-1.el7.x86_64 conflicts with file from package mariadb-libs-1:5.5.44-2.el7.centos.x86_64
        file /usr/share/mysql/charsets/greek.xml from install of mysql-community-common-5.7.18-1.el7.x86_64 conflicts with file from package mariadb-libs-1:5.5.44-2.el7.centos.x86_64
        file /usr/share/mysql/charsets/hebrew.xml from install of mysql-community-common-5.7.18-1.el7.x86_64 conflicts with file from package mariadb-libs-1:5.5.44-2.el7.centos.x86_64
        file /usr/share/mysql/charsets/hp8.xml from install of mysql-community-common-5.7.18-1.el7.x86_64 conflicts with file from package mariadb-libs-1:5.5.44-2.el7.centos.x86_64
        file /usr/share/mysql/charsets/keybcs2.xml from install of mysql-community-common-5.7.18-1.el7.x86_64 conflicts with file from package mariadb-libs-1:5.5.44-2.el7.centos.x86_64
        file /usr/share/mysql/charsets/koi8r.xml from install of mysql-community-common-5.7.18-1.el7.x86_64 conflicts with file from package mariadb-libs-1:5.5.44-2.el7.centos.x86_64
        file /usr/share/mysql/charsets/koi8u.xml from install of mysql-community-common-5.7.18-1.el7.x86_64 conflicts with file from package mariadb-libs-1:5.5.44-2.el7.centos.x86_64
        file /usr/share/mysql/charsets/latin1.xml from install of mysql-community-common-5.7.18-1.el7.x86_64 conflicts with file from package mariadb-libs-1:5.5.44-2.el7.centos.x86_64
        file /usr/share/mysql/charsets/latin2.xml from install of mysql-community-common-5.7.18-1.el7.x86_64 conflicts with file from package mariadb-libs-1:5.5.44-2.el7.centos.x86_64
        file /usr/share/mysql/charsets/latin5.xml from install of mysql-community-common-5.7.18-1.el7.x86_64 conflicts with file from package mariadb-libs-1:5.5.44-2.el7.centos.x86_64
        file /usr/share/mysql/charsets/latin7.xml from install of mysql-community-common-5.7.18-1.el7.x86_64 conflicts with file from package mariadb-libs-1:5.5.44-2.el7.centos.x86_64
        file /usr/share/mysql/charsets/macce.xml from install of mysql-community-common-5.7.18-1.el7.x86_64 conflicts with file from package mariadb-libs-1:5.5.44-2.el7.centos.x86_64
        file /usr/share/mysql/charsets/macroman.xml from install of mysql-community-common-5.7.18-1.el7.x86_64 conflicts with file from package mariadb-libs-1:5.5.44-2.el7.centos.x86_64
        file /usr/share/mysql/charsets/swe7.xml from install of mysql-community-common-5.7.18-1.el7.x86_64 conflicts with file from package mariadb-libs-1:5.5.44-2.el7.centos.x86_64
解决方法:
yum remove mysql-libs  
4,安装
 rpm -ivh mysql-community-libs-5.7.18-1.el7.x86_64.rpm
rpm -ivh mysql-community-client-5.7.18-1.el7.x86_64.rpm
 rpm -ivh  mysql-community-server-5.7.18-1.el7.x86_64.rpm
 rpm -ivh   mysql-community-devel-5.7.18-1.el7.x86_64.rpm

5、启动MySQL

 systemctl start mysqld

6、查看MySQL状态

 systemctl status mysqld
● mysqld.service - MySQL Server
   Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled; vendor preset: disabled)
   Active: active (running) since Tue 2018-03-13 15:41:26 CST; 8s ago
     Docs: man:mysqld(8)
           http://dev.mysql.com/doc/refman/en/using-systemd.html
  Process: 26250 ExecStart=/usr/sbin/mysqld --daemonize --pid-file=/var/run/mysqld/mysqld.pid $MYSQLD_OPTS (code=exited, status=0/SUCCESS)
  Process: 26172 ExecStartPre=/usr/bin/mysqld_pre_systemd (code=exited, status=0/SUCCESS)
 Main PID: 26253 (mysqld)
   CGroup: /system.slice/mysqld.service
           └─26253 /usr/sbin/mysqld --daemonize --pid-file=/var/run/mysqld/mysqld.pid
Mar 13 15:41:20 centos systemd[1]: Starting MySQL Server...

Mar 13 15:41:26 centos systemd[1]: Started MySQL Server.

7、查看密码

cat /var/log/mysqld.log | grep password

8、登录

mysql -u root -p

9、重置密码

SET PASSWORD = PASSWORD('12345678');
Your password does not satisfy the current policy requirements
(密码过于简单,必须大写,小写,数字,符号)改个复杂的


10、查看数据库

show databases;
11、授权远程连接
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '12345678' WITH GRANT OPTION;       
刷新配置: FLUSH PRIVILEGES;    

 




<think>好的,用户现在的问题是需要在CentOS 7安装MySQL 8.0.41RPM bundle包。之前他们遇到了GPG密钥的问题,现在可能已经解决了,或者这是另一个安装场景。我需要先理解用户的需求,然后提供正确的步骤。 首先,用户提供的文件名是mysql-8.0.41-1.el7.x86_64.rpm-bundle.tar,这是一个包含多个RPM包的tar文件。通常,这样的bundle包需要解压后按照依赖顺序安装CentOS 7默认的仓库可能没有MySQL 8.0,所以用户可能选择手动下载RPM bundle安装。 接下来,我需要回忆在CentOS安装MySQL RPM bundle的步骤。通常的步骤包括:安装依赖、下载和解压tar包、按顺序安装各个RPM包,最后启动服务并设置密码。此外,还需要考虑GPG密钥的问题,用户之前遇到过,所以可能需要再次提醒导入密钥或者处理签名验证的问题。 用户可能已经知道使用yum安装的方法,但可能因为网络或其他原因选择手动安装RPM包。这时候需要注意依赖关系,比如common、libs、client、server等包的安装顺序,否则会出现依赖错误。需要明确写出安装顺序,可能使用rpm命令,并加上--nodeps参数,但这样可能有风险,需要提示用户谨慎使用。 另外,安全方面,安装完成后需要运行mysql_secure_installation,设置root密码,移除匿名用户等。这也是必须的步骤,不能遗漏。 用户可能遇到的问题包括依赖缺失,比如需要安装perl和net-tools,或者在安装过程中出现签名验证失败,需要处理GPG密钥。这时候可能需要重复之前的步骤,比如导入GPG密钥,或者临时禁用验证,但需要提醒用户不建议在生产环境这样做。 还需要考虑安装后的配置,比如服务是否启动,是否开机自启。用户可能不熟悉systemctl命令,需要给出具体的命令示例。 最后,用户可能需要验证安装是否成功,比如通过mysql --version和登录数据库。这部分也需要在步骤中体现,确保用户能够确认安装成功。 需要检查是否有遗漏的步骤,比如是否需要配置仓库,或者是否有其他依赖包。此外,如果用户下载的tar包位置不同,解压路径也需要相应调整,需要提醒用户根据实际情况修改命令。 总结起来,回答的结构应该是:步骤清晰的安装过程,包括下载、解压、安装顺序、处理依赖、启动服务、安全设置和验证。同时,提醒可能遇到的问题和解决方案,比如GPG密钥和依赖问题,确保用户能够顺利完成安装。</think>--- ### **CentOS 7 手动安装 MySQL 8.0.41 RPM Bundle 完整指南** --- #### **一、前期准备** 1. **卸载旧版本**(避免冲突): ```bash sudo yum remove mysql-* mariadb-* rm -rf /var/lib/mysql ``` 2. **安装基础依赖**: ```bash sudo yum install -y perl net-tools libaio ``` --- #### **二、安装流程** 1. **下载并解压 Bundle 包** ```bash # 从官网下载(需登录MySQL账户) wget https://dev.mysql.com/get/Downloads/MySQL-8.0/mysql-8.0.41-1.el7.x86_64.rpm-bundle.tar # 创建解压目录 mkdir mysql-rpms && tar -xvf mysql-8.0.41-1.el7.x86_64.rpm-bundle.tar -C mysql-rpms ``` 2. **关键安装顺序**(必须严格按序执行): ```bash cd mysql-rpms sudo rpm -ivh mysql-community-common-8.0.41-1.el7.x86_64.rpm sudo rpm -ivh mysql-community-libs-8.0.41-1.el7.x86_64.rpm sudo rpm -ivh mysql-community-client-8.0.41-1.el7.x86_64.rpm sudo rpm -ivh mysql-community-server-8.0.41-1.el7.x86_64.rpm ``` 3. **处理依赖问题** - 如果出现`libssl.so.10`缺失: ```bash # 安装兼容OpenSSL sudo yum install -y compat-openssl10 ``` - 强制安装(仅限测试环境): ```bash rpm -ivh mysql-community-*.rpm --nodeps --force ``` --- #### **三、配置与启动** 1. **初始化数据库**: ```bash sudo mysqld --initialize --user=mysql # 获取临时密码 sudo grep 'temporary password' /var/log/mysqld.log ``` 2. **启动服务**: ```bash sudo systemctl start mysqld sudo systemctl enable mysqld ``` 3. **安全加固**: ```bash sudo mysql_secure_installation ``` > 按提示设置:新root密码、删除匿名用户、禁止远程root登录、移除测试数据库 --- #### **四、验证安装** 1. **版本检查**: ```bash mysql --version # 应显示:mysql Ver 8.0.41 for Linux on x86_64 (MySQL Community Server) ``` 2. **服务状态**: ```bash systemctl status mysqld ``` 3. **数据库连接测试**: ```bash mysql -u root -p ``` --- #### **五、故障排查** 1. **GPG密钥问题**(若出现): ```bash # 手动导入密钥 sudo rpm --import https://repo.mysql.com/RPM-GPG-KEY-mysql-2022 ``` 2. **文件冲突处理**: ```bash # 检查冲突文件 rpm -qa | grep mysql # 强制卸载旧版本 rpm -e --nodeps [冲突包名] ``` --- #### **六、高级配置建议** 1. **配置文件优化**: ```bash sudo vi /etc/my.cnf ``` 添加基础配置: ```ini [mysqld] default_authentication_plugin=mysql_native_password character-set-server=utf8mb4 collation-server=utf8mb4_unicode_ci ``` 2. **防火墙放行**: ```bash sudo firewall-cmd --permanent --add-service=mysql sudo firewall-cmd --reload ``` --- ### **技术要点说明** - **RPM Bundle 包含组件**: ``` mysql-community-server-* # 主服务 mysql-community-client-* # 客户端工具 mysql-community-libs-* # 共享库 mysql-community-common-* # 配置文件 mysql-community-devel-* # 开发文件(可选) ``` - **与Yum安装的区别**: - 手动安装需自行处理依赖 - 不会自动创建`mysql`系统用户 - 需要手动初始化数据目录 --- ### **替代方案建议** 如果遇到依赖问题难以解决,可改用官方Yum仓库安装: ```bash # 添加MySQL官方仓库 sudo rpm -Uvh https://dev.mysql.com/get/mysql80-community-release-el7-7.noarch.rpm # 标准安装 sudo yum install mysql-community-server ```
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值