linux离线安装mysql5.7
下载安装包
下载地址:https://cdn.mysql.com//Downloads/MySQL-5.7/mysql-5.7.27-1.el7.x86_64.rpm-bundle.tar
上传到 /home 目录下
解压安装包
tar -xf mysql-5.7.27-1.el7.x86_64.rpm-bundle.tar -C /home/mysql/
查询并卸载系统自带的Mariadb
rpm -qa | grep mariadb
rpm -e --nodeps 文件名
查询并卸载系统老旧版本的Mysql
rpm -qa | grep mysql
rpm -e --nodeps 文件名
安装libaio环境(已经存在不需要)
yum install libaio
执行Rpm包安装(按顺序)
rpm -ivh mysql-community-common-5.7.27-1.el7.x86_64.rpm
rpm -ivh mysql-community-libs-5.7.27-1.el7.x86_64.rpm
rpm -ivh mysql-community-devel-5.7.27-1.el7.x86_64.rpm
rpm -ivh mysql-community-libs-compat-5.7.27-1.el7.x86_64.rpm
rpm -ivh mysql-community-client-5.7.27-1.el7.x86_64.rpm
rpm -ivh mysql-community-server-5.7.27-1.el7.x86_64.rpm
启动mysql服务
查看mysql服务是否启动
service mysqld status
启动服务:
systemctl start mysqld
重置root密码
查看随机生成的密码
grep 'temporary password' /var/log/mysqld.log
修改root用户密码
mysql -u root -p
mysql> Enter password: (输入刚才查询到的随机密码)
mysql> SET PASSWORD FOR 'root'@'localhost'= "Jstw@123";
开放外部网段访问3306端口
mysql>GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'Jstw@123' WITH GRANT OPTION;
mysql>FLUSH PRIVILEGES;
mysql> exit
这里设置开机自启动
方法一 、vi /etc/rc.local 添加service mysqld start
方法二 、 执行 systemctl enable mysqld.service
(# 注意systemctl 中规定、服务的配置文件要以.service 为后缀
开启防火墙mysql 3306端口的外部访问
firewall-cmd --zone=public --add-port=3306/tcp --permanent
firewall-cmd --reload
查看已开启的端口
firewall-cmd --list-all
netstat -ntpl (TCP类型已开放的端口)