centos7安装MySQL 8

在centos7上安装mysql 8,有两种方式:

一,在线安装;

二,下载安装包进行安装。

 

一,在线安装

碰到不少坑

1,从官网下载mysql80-community-release-el7-3.noarch.rpm

2,yum localinstall mysql80-community-release-el7-3.noarch.rpm

3,yum -y install mysql-community-server

执行到第4步时,总是会碰到类似如下的错误

Error: Package: mysql-community-server-8.0.18-1.el8.x86_64 (mysql80-community)
           Requires: libssl.so.1.1(OPENSSL_1_1_1)(64bit)
Error: Package: mysql-community-server-8.0.18-1.el8.x86_64 (mysql80-community)
           Requires: libtirpc.so.3(TIRPC_0.3.0)(64bit)
Error: Package: mysql-community-server-8.0.18-1.el8.x86_64 (mysql80-community)
           Requires: libstdc++.so.6(GLIBCXX_3.4.21)(64bit)
Error: Package: mysql-community-server-8.0.18-1.el8.x86_64 (mysql80-community)
           Requires: libcrypto.so.1.1()(64bit)
Error: Package: mysql-community-server-8.0.18-1.el8.x86_64 (mysql80-community)
           Requires: libstdc++.so.6(CXXABI_1.3.11)(64bit)
Error: Package: mysql-community-server-8.0.18-1.el8.x86_64 (mysql80-community)
           Requires: libssl.so.1.1(OPENSSL_1_1_0)(64bit)
Error: Package: mysql-community-server-8.0.18-1.el8.x86_64 (mysql80-community)
           Requires: libstdc++.so.6(CXXABI_1.3.8)(64bit)
Error: Package: mysql-community-server-8.0.18-1.el8.x86_64 (mysql80-community)
           Requires: libstdc++.so.6(GLIBCXX_3.4.22)(64bit)
Error: Package: mysql-community-server-8.0.18-1.el8.x86_64 (mysql80-community)
           Requires: libcrypto.so.1.1(OPENSSL_1_1_0)(64bit)
Error: Package: mysql-community-server-8.0.18-1.el8.x86_64 (mysql80-community)
           Requires: libstdc++.so.6(GLIBCXX_3.4.20)(64bit)
Error: Package: mysql-community-server-8.0.18-1.el8.x86_64 (mysql80-community)
           Requires: libtirpc.so.3()(64bit)
Error: Package: mysql-community-server-8.0.18-1.el8.x86_64 (mysql80-community)
           Requires: libssl.so.1.1()(64bit)
Error: Package: mysql-community-server-8.0.18-1.el8.x86_64 (mysql80-community)
           Requires: libc.so.6(GLIBC_2.28)(64bit)
Error: Package: mysql-community-server-8.0.18-1.el8.x86_64 (mysql80-community)
           Requires: libstdc++.so.6(CXXABI_1.3.9)(64bit)
 You could try using --skip-broken to work around the problem
 You could try running: rpm -Va --nofiles --nodigest

然后网上找解决方案:

yum update

升级openssl

删除MariaDB的文件

删除系统现有的mysql

以上方法均都试过,还是不行。后来在2019 MySQL 8 安全安装避坑指南这篇博客中看到离线安装的方式,最终才安装成功。以下将安装过程整理一下,以备遗忘。

 

二,下载安装包

1,从官网下载安装包(在Centos7上要下载 RH Linux 7 的安装包)

https://dev.mysql.com/downloads/mysql/

mysql-8.0.17-1.el7.x86_64.rpm-bundle.tar

2,清理环境

2.1 查看系统是否已经安装了mysql数据库

rpm -qa | grep mysql

2.2 将查询出的文件逐个删除,如

yum remove mysql-community-common-5.7.20-1.el6.x86_64

2.3 删除mysql的配置文件

find / -name mysql

2.4 删除配置文件

rm -rf /var/lib/mysql

2.5删除MariaDB文件

rpm -pa | grep mariadb

删除查找出的相关文件和目录,如

yum -y remove mariadb-libs.x86_64

3,安装

3.1解压

tar -xf mysql-8.0.17-1.el7.x86_64.rpm-bundle.tar

3.2安装

yum install mysql-community-{client,common,devel,embedded,libs,server}-*

等待安装成功!

4,配置

4.1 启动mysqld服务,并设为开机自动启动。命令:

systemctl start mysqld.service //这是centos7的命令
systemctl enable mysqld.service

4.2 通过如下命令可以在日志文件中找出密码:

grep "password" /var/log/mysqld.log

4.3按照日志文件中的密码,进入数据库

mysql -uroot -p

4.4设置密码(注意Mysql8密码设置规则必须是大小写字母+特殊符号+数字的类型)

ALTER USER 'root'@'localhost' IDENTIFIED BY 'new password';

4.5开启远程访问

use mysql;

ALTER USER 'root'@'%' IDENTIFIED WITH mysql_native_password BY '你的密码';

FLUSH PRIVILEGES;

4.6更改语言

打开/etc/my.cnf

添加如下语句

[client]
default-character-set=utf8

......

character-set-server=utf8
collation-server=utf8_general_ci

保存

4.7重启

systemctl restart mysqld

4.8重新登录mysql,查看status

 

5,可以在windows上用Navicat远程登录mysql了。

 

 

参考:

https://blog.csdn.net/wujiandao/article/details/100502733

https://blog.csdn.net/chrisjingu/article/details/90291445

https://blog.csdn.net/qq_36582604/article/details/80526287

https://www.jianshu.com/p/7b8c4dea6829

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

来灵

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值