什么都不要想先去官网看看:
https://dev.mysql.com/doc/mysql-yum-repo-quick-guide/en/#repo-qg-yum-installing
repo 源下载地址: https://dev.mysql.com/downloads/repo/yum/
最好先su root 先切换到root
rpm -ivh mysql80-community-release-el8-1.noarch.rpm
然后 yum repolist all | grep mysql 看下是不是有mysql的信息,里面应该没有5.7的源,需要修改
/etc/yum.repo.d/mysql-community.repo 文件
vi /etc/yum.repo.d/mysql-community.repo
官网的是:
[mysql57-community]
name=MySQL 5.7 Community Server
baseurl=http://repo.mysql.com/yum/mysql-5.7-community/el/6/$basearch/
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql
但是会报错,少了 libsasl2.so.2()(64bit) 需要改成:
[mysql57-community]
name=MySQL 5.7 Community Server
baseurl=http://repo.mysql.com/yum/mysql-5.7-community/el/7/$basearch/
enabled=1
gpgcheck=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql
:wq 保存
查看mysql安装源 yum repolist enabled | grep mysql
如果存在两个mysql*-community enable 需要禁掉一个,最好修改源的时候 将其中一个 enabled=0
如我的: yum-config-manager --disable mysql80-community
变成上图只有一个enable就可以开始下一步了
还需要执行 yum module disable mysql 官网这样解释的
(EL8 systems only) EL8-based systems such as RHEL8 and Oracle Linux 8 include a MySQL module that is enabled by default. Unless this module is disabled, it masks packages provided by MySQL repositories. To disable the included module and make the MySQL repository packages visible, use the following command (for dnf-enabled systems, replace yum in the command with dnf
(仅限EL8系统)基于RHEL8和Oracle Linux 8的基于EL8的系统包括默认情况下启用的MySQL模块。 除非禁用此模块,否则它将屏蔽MySQL存储库提供的软件包。 要禁用包含的模块并使MySQL存储库软件包可见,请使用以下命令(对于启用了dnf的系统,请将该命令中的yum替换为dnf
接下来就可以愉快的安装了 yum install mysql-community-server
安装完成后 开启mysql systemctl start mysqld
查看是否启动 systemctl status mysqld
接下来就可以进去看看了 mysql -u root -p 密码在 /var/log/mysqld.log
第一步就是 ALTER USER 'root'@'localhost' IDENTIFIED BY 'MyNewPass4!'; 设置密码(需要遵守密码规则)
然后:use mysql ;
如果还需要添加新的账号或者用户,包括远程那些 :
grant all privileges on *.* to root @"%" identified by "password."; //% 任何ip可以连接
flush privileges; //刷新才能生效
第三方软件连接试试 不行看看防火墙是不是开了
systemctl status firewalld 查看防火墙状态
systemctl stop firewalld 关闭防火墙
systemctl disable firewalld 不需要开机自启