1. 程式人生 > >CentOS7安裝MySql,防火牆關閉,遠端訪問

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