Centos7.6.1810安装MySQL8.0.27图文详解
由于最新换了新电脑,之前电脑里的虚拟机都删除了,突然想到还有项目需要MySQL数据库,所以想再重新安装一次;最初是想使用手动自定义安装,下载了文件之后,安装时发现总是在修改配置文件那步出错,无法继续安装;耽误了很长时间,由于上一台电脑安装MySQL时没有写操作手册,所以这次过程很艰难,直到在网上找到了这篇文章才得以解决,从安装成功到写文档只用了一个工作日,非常方便;特此将安装步骤发布如下: 以下安装步骤省略了虚拟机安装Linux系统和MySQL文件上传至虚拟机两部分;
主要参考了CentOS7安装MySQL8.0图文教程; 在此感谢原博主;
1.使用命令cat /etc/redhat-release确定Linux系统版本,此命令只针对RedHat的Linux系统;  2.使用uname -r和uname -a确定系统的是32位还是64位;  3.登录MySQL官网:https://www.mysql.com/;点击DOWMLOADS;  4.选择最下方下载服务“MySQL Community (GPL) Downloads ?”;  5.选择“MySQL Community Server”;  6.要注意根据Linux系统版本和位数选择对应的MySQL版本;在“Download Packages:”中选择第一个下载;  7.点击下方“No thanks, just start my download.”无需登录直接下载;  8.使用命令rpm -qa | grep mariadb查看操作系统中是否有自带的MySQL文件;  9.使用命令rpm -e mariadb-libs-5.5.60-1.el7_5.x86_64 –nodeps删除自带的MySQL文件;  10.使用命令rpm -qa | grep mariadb再检查一遍是否还存在,如果为空,代表卸载完毕;  11.使用命令cd /usr/local进入文件夹;  12.使用命令mkdir mysql新建一个mysql文件夹; 使用命令cd mysql进入mysql文件夹;  13.使用命令tar -xvf mysql-8.0.27-1.el7.x86_64.rpm-bundle.tar解压下载的mysql安装文件;  14.使用命令解压后为以下rpm文件;  15.使用以下命令: ①rpm -ivh mysql-community-common-8.0.27-1.el7.x86_64.rpm --nodeps –force ② rpm -ivh mysql-community-libs-8.0.27-1.el7.x86_64.rpm --nodeps --force ③ rpm -ivh mysql-community-client-8.0.27-1.el7.x86_64.rpm --nodeps --force ④ rpm -ivh mysql-community-server-8.0.27-1.el7.x86_64.rpm --nodeps –force  16.使用命令rpm -qa | grep mysql检查mysql是否安装成功;  17.使用命令mysqld –initialize初始化;  18.使用命令chown mysql:mysql /var/lib/mysql -R配置权限;注意:一定要用**/var/lib/mysql**文件夹;  19. 使用命令systemctl start mysqld.service启动服务;
20.使用命令systemctl enable mysqld设置开机自启;  21.使用命令cat /var/log/mysqld.log | grep password查看生成的密码;  22.使用命令mysql -uroot -p登录mysql服务;  23.使用命令ALTER USER ‘root’@‘localhost’ IDENTIFIED WITH mysql_native_password BY ‘mysql@8027’ 设置密码;“mysql@8027”代表新设置的密码;使用命令exit退出;  24.使用命令mysql -uroot -p重新登录查验,使用新密码;  25.使用以下命令,设置远程访问授权: ① create user 'root'@'%' identified with mysql_native_password by 'mysql@8027' ② grant all privileges on *.* to 'root'@'%' with grant option ③flush privileges 执行完毕后,退出mysql;  26.使用命令关闭防火墙: ① systemctl stop firewalld.service ② systemctl disable firewalld.service ③ systemctl mask firewalld.service  27.使用命令yum -y install iptables-services安装 iptables 防火墙;  注: 由于镜像地址或者网络问题,会导致多次下载失败,无需手动干预,多等一会儿就会自动安装完成;    28.使用命令systemctl enable iptables设置开机自启防火墙;  29.使用命令systemctl start iptables设置启动防火墙;  30.使用命令vi /etc/sysconfig/iptables设置防火墙配置文件;  ① -A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT ② -A INPUT -m state --state NEW -m tcp -p tcp --dport 3306 -j ACCEPT ③ -A INPUT -m state --state NEW -m tcp -p tcp --dport 443 -j ACCEPT ④ -A INPUT -m state --state NEW -m tcp -p tcp --dport 8080 -j ACCEPT ⑤ -A INPUT -m state --state NEW -m tcp -p tcp --dport 8090 -j ACCEPT  31.使用命令systemctl restart iptables.service重启防火墙服务; 32.使用命令systemctl enable iptables.service设置防火墙开机自启;  33.使用Navicat测试连接; 
以上步骤就是安装MySQL的其中一种方法,相当于自动安装,大部分配置属性都是默认的,应该还有一种自定义配置文件的安装方法(主要是配置文件的设置),希望看到的朋友不吝赐教,互相学习!!!
|