文章目录
在RHEL7.x中安装MySQL8
查看操作系统信息
[root@localhost ~]# cat /etc/system-release
Red Hat Enterprise Linux Server release 7.9 (Maipo)
[root@localhost ~]#
查看当前仓库源配置
yum repolist enabled
结果如下:
[root@localhost tmp]# yum repolist enabled
已加载插件:product-id, search-disabled-repos, subscription-manager
源标识 源名称 状态
!rhel-7-server-rpms/7Server/x86_64 Red Hat Enterprise Linux 7 Server (RPMs) 33,276
repolist: 33,276
[root@localhost tmp]#
删除旧的mysql和mariadb
yum remove mysql-*
yum remove mariadb*
安装MySQL8官方仓库源
从MySQL官方网站下载仓库源安装包并安装,注意需要与操作系统匹配。
cd /tmp/
wget --no-check-certificate https://dev.mysql.com/get/mysql80-community-release-el7-7.noarch.rpm
yum install mysql80-community-release-el7-7.noarch.rpm
更新仓库缓存
因为没有RedHat的账号,需要禁用rhel-7-server-rpms仓库,使用操作系统安装ISO文件作为替代仓库源。
subscription-manager repos --disable=rhel-7-server-rpms
yum clean all
mount /dev/cdrom /media # 过载操作系统镜像文件
cp /media/media.repo /etc/yum.repo.d/
在 media.repo
文件的最后添加下面的内容:
baseurl=file:///media
enabled=1
更新缓存
yum makecache
查看安装MySQL8仓库源后的仓库配置
[root@localhost yum.repos.d]# yum repolist enabled
已加载插件:product-id, search-disabled-repos, subscription-manager
源标识 源名称 状态
InstallMedia Red Hat Enterprise Linux 7.1 4,371
mysql-connectors-community/x86_64 MySQL Connectors Community 206
mysql-tools-community/x86_64 MySQL Tools Community 94
mysql80-community/x86_64 MySQL 8.0 Community Server 367
repolist: 5,038
[root@localhost yum.repos.d]#
安装MySQL8
yum install mysql-community-server
启动MySQL8
设置开机自启动
systemctl enable mysqld
启动mysqld服务
systemctl start mysqld
查看服务监听端口
ss -nlt
State Recv-Q Send-Q Local Address:Port Peer Address:Port
LISTEN 0 128 *:22 *:*
LISTEN 0 100 127.0.0.1:25 *:*
LISTEN 0 128 [::]:22 [::]:*
LISTEN 0 100 [::1]:25 [::]:*
LISTEN 0 70 [::]:33060 [::]:*
LISTEN 0 128 [::]:3306 [::]:*
[root@localhost yum.repos.d]#
查看初始化密码:
grep 'temporary password' /var/log/mysqld.log
2022-10-12T14:17:48.870899Z 6 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: ?J2-zukKMXY8
修改初始密码:
mysql -u root -p # 输入初始密码
ALTER user 'root'@'localhost' IDENTIFIED BY 'Xnecas@123$%';
导入数据
mysql -u root -p # 输入新密码
source /tmp/modanai_db.sql
exit
仅供参考,如有帮助不胜荣幸,如需转载请注明出处。
请关注、点赞、收藏。