CentOS 7安装 mysql-8.0.27-1.el7.x86_64.rpm 安装包
访问地址:
https://mirrors.aliyun.com/mysql/MySQL-8.0/?spm=a2c6h.25603864.0.0.17ec2ca8dkeWtv
CentOS 7 专用的 MySQL 8.0 安装包就是下面这个:
mysql-8.0.27-1.el7.x86_64.rpm-bundle.tar✅ 下载 & 安装步骤
1. 下载这个包(两种方式)
- 方式 1:浏览器直接下点这个文件下载,保存到电脑,再上传到你的 CentOS 7 服务器上。
- 方式 2:服务器上用 wget 直接下
wget https://mirrors.aliyun.com/mysql/MySQL-8.0/mysql-8.0.27-1.el7.x86_64.rpm-bundle.tar
2. 解压安装包
# 解压 tar 包 tar -xvf mysql-8.0.27-1.el7.x86_64.rpm-bundle.tar # 解压后会生成一堆 .rpm 文件,我们只需要安装核心的几个: # mysql-community-common-*.rpm # mysql-community-libs-*.rpm # mysql-community-client-*.rpm # mysql-community-server-*.rpm
3. 按顺序安装(解决依赖)
# 先卸载系统自带的 mariadb-libs,避免冲突 yum remove -y mariadb-libs# 安装依赖包 rpm -ivh mysql-community-common-8.0.27-1.el7.x86_64.rpm rpm -ivh mysql-community-libs-8.0.27-1.el7.x86_64.rpm rpm -ivh mysql-community-client-8.0.27-1.el7.x86_64.rpm rpm -ivh mysql-community-server-8.0.27-1.el7.x86_64.rpm #------------------------------------------ # 或者使用下面安装 rpm -ivh mysql-community-*.rpm --nodeps --force4. 启动 & 初始化 MySQL
# 启动服务 systemctl start mysqld # 开机自启 systemctl enable mysqld # 查看初始临时密码 grep 'temporary password' /var/log/mysqld.log # 登录并修改密码 mysql -uroot -p ALTER USER 'root'@'localhost' IDENTIFIED BY '你的强密码';卸载现在装坏的 MySQL(必须做)
rpm -e --nodeps mysql-community-server rpm -e --nodeps mysql-community-client rpm -e --nodeps mysql-community-libs rpm -e --nodeps mysql-community-common rpm -e --nodeps mysql-community-client-plugins启动报错
Job for mysqld.service failed because the control process exited with error code. See "systemctl status mysqld.service" and "journalctl -xe" for details.
看启动失败的具体原因
先执行下面的命令,看看到底是什么问题:
# 查看服务状态 systemctl status mysqld.service # 查看详细日志 journalctl -xe | grep mysqldjournalctl -xe | grep mysqld -- Subject: Unit mysqld.service has begun start-up -- Unit mysqld.service has begun starting up. May 13 12:52:48 iZ0jlgpxxeb31ngiadjy9gZ mysqld_pre_systemd[64967]: /usr/bin/my_print_defaults: error while loading shared libraries: libssl.so.10: cannot open shared object file: No such file or directory May 13 12:52:48 iZ0jlgpxxeb31ngiadjy9gZ mysqld_pre_systemd[64973]: /usr/bin/my_print_defaults: error while loading shared libraries: libssl.so.10: cannot open shared object file: No such file or directory May 13 12:52:48 iZ0jlgpxxeb31ngiadjy9gZ mysqld_pre_systemd[64979]: /usr/bin/my_print_defaults: error while loading shared libraries: libssl.so.10: cannot open shared object file: No such file or directory May 13 12:52:48 iZ0jlgpxxeb31ngiadjy9gZ mysqld_pre_systemd[64993]: /usr/sbin/mysqld: error while loading shared libraries: libssl.so.10: cannot open shared object file: No such file or directory May 13 12:52:48 iZ0jlgpxxeb31ngiadjy9gZ mysqld[64997]: /usr/sbin/mysqld: error while loading shared libraries: libssl.so.10: cannot open shared object file: No such file or directory May 13 12:52:48 iZ0jlgpxxeb31ngiadjy9gZ systemd[1]: mysqld.service: Main process exited, code=exited, status=127/n/a May 13 12:52:48 iZ0jlgpxxeb31ngiadjy9gZ systemd[1]: mysqld.service: Failed with result 'exit-code'. -- The unit mysqld.service has entered the 'failed' state with result 'exit-code'. -- Subject: Unit mysqld.service has failed -- Unit mysqld.service has failed. May 13 12:52:48 iZ0jlgpxxeb31ngiadjy9gZ systemd[1]: mysqld.service: Service RestartSec=100ms expired, scheduling restart. May 13 12:52:48 iZ0jlgpxxeb31ngiadjy9gZ systemd[1]: mysqld.service: Scheduled restart job, restart counter is at 1. -- Automatic restarting of the unit mysqld.service has been scheduled, as the result for -- Subject: Unit mysqld.service has finished shutting down -- Unit mysqld.service has finished shutting down. -- Subject: Unit mysqld.service has begun start-up -- Unit mysqld.service has begun starting up. May 13 12:52:48 iZ0jlgpxxeb31ngiadjy9gZ mysqld_pre_systemd[65004]: /usr/bin/my_print_defaults: error while loading shared libraries: libssl.so.10: cannot open shared object file: No such file or directory May 13 12:52:48 iZ0jlgpxxeb31ngiadjy9gZ mysqld_pre_systemd[65010]: /usr/bin/my_print_defaults: error while loading shared libraries: libssl.so.10: cannot open shared object file: No such file or directory May 13 12:52:48 iZ0jlgpxxeb31ngiadjy9gZ mysqld_pre_systemd[65016]: /usr/bin/my_print_defaults: error while loading shared libraries: libssl.so.10: cannot open shared object file: No such file or directory May 13 12:52:48 iZ0jlgpxxeb31ngiadjy9gZ mysqld_pre_systemd[65028]: /usr/sbin/mysqld: error while loading shared libraries: libssl.so.10: cannot open shared object file: No such file or directory May 13 12:52:48 iZ0jlgpxxeb31ngiadjy9gZ mysqld[65032]: /usr/sbin/mysqld: error while loading shared libraries: libssl.so.10: cannot open shared object file: No such file or directory May 13 12:52:48 iZ0jlgpxxeb31ngiadjy9gZ systemd[1]: mysqld.service: Main process exited, code=exited, status=127/n/a May 13 12:52:48 iZ0jlgpxxeb31ngiadjy9gZ systemd[1]: mysqld.service: Failed with result 'exit-code'. -- The unit mysqld.service has entered the 'failed' state with result 'exit-code'. -- Subject: Unit mysqld.service has failed -- Unit mysqld.service has failed. May 13 12:52:48 iZ0jlgpxxeb31ngiadjy9gZ systemd[1]: mysqld.service: Service RestartSec=100ms expired, scheduling restart. May 13 12:52:48 iZ0jlgpxxeb31ngiadjy9gZ systemd[1]: mysqld.service: Scheduled restart job, restart counter is at 2. -- Automatic restarting of the unit mysqld.service has been scheduled, as the result for -- Subject: Unit mysqld.service has finished shutting down -- Unit mysqld.service has finished shutting down. -- Subject: Unit mysqld.service has begun start-up -- Unit mysqld.service has begun starting up. May 13 12:52:48 iZ0jlgpxxeb31ngiadjy9gZ mysqld_pre_systemd[65044]: /usr/bin/my_print_defaults: error while loading shared libraries: libssl.so.10: cannot open shared object file: No such file or directory May 13 12:52:48 iZ0jlgpxxeb31ngiadjy9gZ mysqld_pre_systemd[65050]: /usr/bin/my_print_defaults: error while loading shared libraries: libssl.so.10: cannot open shared object file: No such file or directory May 13 12:52:48 iZ0jlgpxxeb31ngiadjy9gZ mysqld_pre_systemd[65056]: /usr/bin/my_print_defaults: error while loading shared libraries: libssl.so.10: cannot open shared object file: No such file or directory May 13 12:52:48 iZ0jlgpxxeb31ngiadjy9gZ mysqld_pre_systemd[65068]: /usr/sbin/mysqld: error while loading shared libraries: libssl.so.10: cannot open shared object file: No such file or directory May 13 12:52:48 iZ0jlgpxxeb31ngiadjy9gZ mysqld[65072]: /usr/sbin/mysqld: error while loading shared libraries: libssl.so.10: cannot open shared object file: No such file or directory May 13 12:52:48 iZ0jlgpxxeb31ngiadjy9gZ systemd[1]: mysqld.service: Main process exited, code=exited, status=127/n/a May 13 12:52:48 iZ0jlgpxxeb31ngiadjy9gZ systemd[1]: mysqld.service: Failed with result 'exit-code'. -- The unit mysqld.service has entered the 'failed' state with result 'exit-code'. -- Subject: Unit mysqld.service has failed -- Unit mysqld.service has failed. May 13 12:52:49 iZ0jlgpxxeb31ngiadjy9gZ systemd[1]: mysqld.service: Service RestartSec=100ms expired, scheduling restart. May 13 12:52:49 iZ0jlgpxxeb31ngiadjy9gZ systemd[1]: mysqld.service: Scheduled restart job, restart counter is at 3. -- Automatic restarting of the unit mysqld.service has been scheduled, as the result for -- Subject: Unit mysqld.service has finished shutting down -- Unit mysqld.service has finished shutting down. -- Subject: Unit mysqld.service has begun start-up -- Unit mysqld.service has begun starting up. May 13 12:52:49 iZ0jlgpxxeb31ngiadjy9gZ mysqld_pre_systemd[65077]: /usr/bin/my_print_defaults: error while loading shared libraries: libssl.so.10: cannot open shared object file: No such file or directory May 13 12:52:49 iZ0jlgpxxeb31ngiadjy9gZ mysqld_pre_systemd[65083]: /usr/bin/my_print_defaults: error while loading shared libraries: libssl.so.10: cannot open shared object file: No such file or directory May 13 12:52:49 iZ0jlgpxxeb31ngiadjy9gZ mysqld_pre_systemd[65089]: /usr/bin/my_print_defaults: error while loading shared libraries: libssl.so.10: cannot open shared object file: No such file or directory May 13 12:52:49 iZ0jlgpxxeb31ngiadjy9gZ mysqld_pre_systemd[65101]: /usr/sbin/mysqld: error while loading shared libraries: libssl.so.10: cannot open shared object file: No such file or directory May 13 12:52:49 iZ0jlgpxxeb31ngiadjy9gZ mysqld[65105]: /usr/sbin/mysqld: error while loading shared libraries: libssl.so.10: cannot open shared object file: No such file or directory May 13 12:52:49 iZ0jlgpxxeb31ngiadjy9gZ systemd[1]: mysqld.service: Main process exited, code=exited, status=127/n/a May 13 12:52:49 iZ0jlgpxxeb31ngiadjy9gZ systemd[1]: mysqld.service: Failed with result 'exit-code'. -- The unit mysqld.service has entered the 'failed' state with result 'exit-code'. -- Subject: Unit mysqld.service has failed -- Unit mysqld.service has failed. May 13 12:52:49 iZ0jlgpxxeb31ngiadjy9gZ systemd[1]: mysqld.service: Service RestartSec=100ms expired, scheduling restart. May 13 12:52:49 iZ0jlgpxxeb31ngiadjy9gZ systemd[1]: mysqld.service: Scheduled restart job, restart counter is at 4. -- Automatic restarting of the unit mysqld.service has been scheduled, as the result for -- Subject: Unit mysqld.service has finished shutting down -- Unit mysqld.service has finished shutting down. -- Subject: Unit mysqld.service has begun start-up -- Unit mysqld.service has begun starting up. May 13 12:52:49 iZ0jlgpxxeb31ngiadjy9gZ mysqld_pre_systemd[65111]: /usr/bin/my_print_defaults: error while loading shared libraries: libssl.so.10: cannot open shared object file: No such file or directory May 13 12:52:49 iZ0jlgpxxeb31ngiadjy9gZ mysqld_pre_systemd[65117]: /usr/bin/my_print_defaults: error while loading shared libraries: libssl.so.10: cannot open shared object file: No such file or directory May 13 12:52:49 iZ0jlgpxxeb31ngiadjy9gZ mysqld_pre_systemd[65123]: /usr/bin/my_print_defaults: error while loading shared libraries: libssl.so.10: cannot open shared object file: No such file or directory May 13 12:52:49 iZ0jlgpxxeb31ngiadjy9gZ mysqld_pre_systemd[65135]: /usr/sbin/mysqld: error while loading shared libraries: libssl.so.10: cannot open shared object file: No such file or directory May 13 12:52:49 iZ0jlgpxxeb31ngiadjy9gZ mysqld[65139]: /usr/sbin/mysqld: error while loading shared libraries: libssl.so.10: cannot open shared object file: No such file or directory May 13 12:52:49 iZ0jlgpxxeb31ngiadjy9gZ systemd[1]: mysqld.service: Main process exited, code=exited, status=127/n/a May 13 12:52:49 iZ0jlgpxxeb31ngiadjy9gZ systemd[1]: mysqld.service: Failed with result 'exit-code'. -- The unit mysqld.service has entered the 'failed' state with result 'exit-code'. -- Subject: Unit mysqld.service has failed -- Unit mysqld.service has failed. May 13 12:52:49 iZ0jlgpxxeb31ngiadjy9gZ systemd[1]: mysqld.service: Service RestartSec=100ms expired, scheduling restart. May 13 12:52:49 iZ0jlgpxxeb31ngiadjy9gZ systemd[1]: mysqld.service: Scheduled restart job, restart counter is at 5. -- Automatic restarting of the unit mysqld.service has been scheduled, as the result for -- Subject: Unit mysqld.service has finished shutting down -- Unit mysqld.service has finished shutting down. May 13 12:52:49 iZ0jlgpxxeb31ngiadjy9gZ systemd[1]: mysqld.service: Start request repeated too quickly. May 13 12:52:49 iZ0jlgpxxeb31ngiadjy9gZ systemd[1]: mysqld.service: Failed with result 'exit-code'. -- The unit mysqld.service has entered the 'failed' state with result 'exit-code'. -- Subject: Unit mysqld.service has failed -- Unit mysqld.service has failed.核心报错只有一句:
libssl.so.10: cannot open shared object file: No such file or directory
你的 CentOS7缺少 OpenSSL10 兼容库,所以 MySQL 启动直接失败。我现在给你一键修复命令,复制运行就能解决!
🔥 直接复制这 3 行,100% 解决问题
yum install -y openssl10 openssl10-devel ln -s /usr/lib64/libssl.so.10 /usr/lib64/libssl.so.1.0.0 ln -s /usr/lib64/libcrypto.so.10 /usr/lib64/libcrypto.so.1.0.0