系统环境: Centos 7.6 数据库版本: Server version: 8.0.17 MySQL 关闭selinux和 防火墙 下载依赖包: yum install -y net-tools 卸载系统初始自带的MariaDB #yum remove -y mariadb* 1、浏览器搜索MySQL

2、导航栏点击下载

3、下拉找到社区版

4、下载包含比较全的包 或者直接下载我提供的链接: wget https://cdn.mysql.com//Downloads/MySQL-8.0/mysql-8.0.17-1.el7.x86_64.rpm-bundle.tar

再或者用MySQL 5.7版本也适合该环境 wget https://cdn.mysql.com//Downloads/MySQL-5.7/mysql-5.7.27-1.el7.x86_64.rpm-bundle.tar

5、下载完成后,上传并解压包

6、安装顺序依次安装 1、 rpm -ivh mysql-community-common-8.0.17-1.el7.x86_64.rpm 2、 rpm -ivh mysql-community-libs-8.0.17-1.el7.x86_64.rpm 3、 rpm -ivh mysql-community-client-8.0.17-1.el7.x86_64.rpm 4、 rpm -ivh mysql-community-server-8.0.17-1.el7.x86_64.rpm

7、查看mysql安装时自动生成的初始密码 systemctl start mysqld cat /var/log/mysqld.log | grep "temporary password" 登陆后修改密码(一定要设置安全度高的密码,否则报错:不符合安全策略) set password for root@localhost = password('Admin12345.'); 或者 SET PASSWORD = 'Admin12345.' 8、或者打开/etc/my.cnf文件设置免密码登录 8、保存重启MySQL

9、登陆 10、设置远程登陆 选择mysql库 use mysql; 更新user表,授权所有主机(host=%)可以远程,授权root用户 update user set host = '%' where user = 'root'; 刷新表 flush privileges; 创建一个adm日常用户 grant all on . to adm@'%' identified by 'Admin12345.' with grant option; 刷新表 flush privileges;