Centos7 安装 MySQL5.7

Centos安装MySQL

官网yum repository 下载安装包

wget http://dev.mysql.com/get/mysql80-community-release-el6-3.noarch.rpm

安装下载下来的rpm包
yum localinstall mysql80-community-release-el6-3.noarch.rpm

查看可用的安装包

yum repolist enabled|grep mysql

image

更改mysql版本

vim /etc/yum.repos.d/mysql-community.repo

image

MySQL8.0 的 enable = 0,MySQL5.7 的 enable = 1

安装mysql

yum install mysql-community-server -y

启动mysql并更改相关配置

  • 启动mysql

service mysqld start

  • 查看mysql是否自启动,并且设置开启自启动

chkconfig --list | grep mysqld

chkconfig mysqld on

  • 查看初始密码

grep "password" /var/log/mysqld.log

image

  • 修改密码

SET PASSWORD FOR 'root'@'localhost' = PASSWORD('123456');

修改的密码过于简单可能会报错:

ERROR 1819 (HY000): Your password does not satisfy the current policy requirements

执行以下语句:

set global validate_password_policy=0;

set global validate_password_length=4;

再执行修改密码语句

  • 开放root账户远程访问

grant all privileges on *.* to 'root'@'%' identified by '123456' with grant option;

  • 刷新权限表

FLUSH PRIVILEGES;

打开3306端口远程访问

将centos7自带的firewall防火墙更换为iptables防火墙

1、关闭firewall防火墙

[root@centos7 html]# systemctl stop firewalld #停止firewall防火墙
[root@centos7 html]# systemctl disable firewalld  #禁止firewall开机启动
[root@centos7 html]# systemctl status firewalld
● firewalld.service - firewalld - dynamic firewall daemon
   Loaded: loaded (/usr/lib/systemd/system/firewalld.service; disabled; vendor preset: enabled)
   Active: inactive (dead)
     Docs: man:firewalld(1)

2、安装iptables防火墙并设置自启动

安装

[root@centos7 html]# yum install  -y iptables  iptables-services

自启动设置

[root@centos7 html]# systemctl enable iptables
Created symlink from /etc/systemd/system/basic.target.wants/iptables.service to /usr/lib/systemd/system/iptables.service.
[root@centos7 html]# systemctl status iptables
● iptables.service - IPv4 firewall with iptables
   Loaded: loaded (/usr/lib/systemd/system/iptables.service; enabled; vendor preset: disabled)
   Active: active (exited) since Fri 2017-08-18 23:41:19 CST; 2min 22s ago
 Main PID: 3603 (code=exited, status=0/SUCCESS)

3、查看iptables配置文件,添加3306端口

打开iptables文件

vi /etc/sysconfig/iptables

进入编辑页面,在指定位置新增以下配置。放在 -A INPUT -m state –state NEW -m tcp -p tcp –dport 22 -j ACCEPT 后面

-A INPUT -m state --state NEW -m tcp -p tcp --dport 3306 -j ACCEPT

修改完保存退出,重启网卡服务

service iptables restart

查看端口开放信息

service iptables status

参考阅读
VMware安装Centos7超详细过程(图文)

yum 安装pip

如何将centos7自带的firewall防火墙更换为iptables防火墙

yum安装MySQL软件时报错libmysqlclient.so.18()(64bit)

yum mysql 需要:libsasl2.so.2()(64bit)的解决办法

centos 6.5如何安装mysql

CentOS7安装MySQL报错Failed to start mysqld.service: Unit not found解决办法

如何在本地远程连接linux虚拟机上面的mysql

CentOS 7下启动、关闭、重启、查看MySQL服务

Navicat无法连接虚拟机MySQL, 需要打开linux的3306端口

Host 'xxxx' is not allowed to connect to this MySQL server

centos7 中查看log_bin是否开启以及开启log_bin

mysql5.7(或pxc5.7) 错误日志显示时间不对解决方案

posted @ 2021-06-09 00:23  NEW_DAY_NEW_LIFE  阅读(88)  评论(0)    收藏  举报