CentOS7安装MySql,防火墙关闭,远程访问

一、centos7安装MySQL

CentOS 7的yum源中貌似没有正常安装mysql时的mysql-sever文件,需要去官网上下载

# wget http://dev.mysql.com/get/mysql-community-release-el7-5.noarch.rpm
# rpm -ivh mysql-community-release-el7-5.noarch.rpm
# yum install mysql-community-server

成功安装之后重启mysql服务

# service mysqld restart

初次安装mysql是root账户是没有密码的

设置密码的方法

# mysql -uroot
mysql> set password for ‘root’@‘localhost’ = password('mypasswd');
mysql> exit;
二、centos7关闭防火墙

1. Disable Firewalld Service.

[root@rhel-centos7-tejas-barot-linux ~]# systemctl mask firewalld

2. Stop Firewalld Service.

[root@rhel-centos7-tejas-barot-linux ~]# systemctl stop firewalld

3. Install iptables service related packages.

[root@rhel-centos7-tejas-barot-linux ~]# yum -y install iptables-services

4. Make sure service starts at boot:

[root@rhel-centos7-tejas-barot-linux ~]# systemctl enable iptables

# If you do not want ip6tables, You can skip following command.

[root@rhel-centos7-tejas-barot-linux ~]# systemctl enable ip6tables

5. Now, Finally Let’s start the iptables services.

[root@rhel-centos7-tejas-barot-linux ~]# systemctl start iptables

# If you do not want ip6tables, You can skip following command.

[root@rhel-centos7-tejas-barot-linux ~]# systemctl start ip6tables

三、允许远程登录

GRANT ALL PRIVILEGES ON *.* TO 'root'@'%'IDENTIFIED BY '123456' WITH GRANT OPTION; 
FLUSH PRIVILEGES ;


参考资料: http://www.centoscn.com/mysql/2014/0930/3881.html

参考资料:http://www.centoscn.com/CentOS/2015/0313/4877.html

你可能感兴趣的:(Linux)