Centos7在线安装MySQL5.6

1.rpm下载mysql包

wget http://repo.mysql.com/mysql-community-release-el7-5.noarch.rpm

2.安装mysql和mysql服务

    rpm -ivh mysql-community-release-el7-5.noarch.rpm

    yum -y install mysql-server



3.检查是否安装成功

#启动MySQL

systemctl start mysqld

#查看MySQL状态

systemctl status mysqld

#出现绿色的Active:active(running)

4.给root用户添加密码

        mysqladmin -u root password "111111"


5.登录MySQL


        mysql -u root -p


6.远程登陆mysql

需要给mysql的root用户添加权限,这里需要在mysql的界面内输入

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


7.mysql远程登录使用的是3306端口,所以防火墙也要开启相应的端口


[root@localhost ~]# firewall-cmd --add-port=3306/tcp --permanent
success
[root@localhost ~]# systemctl restart firewalld
[root@localhost ~]# firewall-cmd --list-all
public (active)
  target: default
  icmp-block-inversion: no
  interfaces: ens33
  sources:
  services: dhcpv6-client ssh
  ports: 3306/tcp
  protocols:
  masquerade: no
  forward-ports:
  source-ports:
  icmp-blocks:
  rich rules:







记住修改下时区



#查看时区

timedatectl


#修改时区+8

timedatectl set-timezone Asia/Shanghai