Thứ Ba, 23 tháng 2, 2016

Guides enabled MySQL Remote Access

If you want to enable Remote Access to connect to MySQL from a personal computer or from another server, follow the steps below.

1. Change the MySQL configuration

By default MySQL will disable remote access, you need to enable up by opening the MySQL configuration file, for example the path /etc/mysql/my.cnf

nano /etc/mysql/my.cnf

Comment the following line:

Bind-address = 127.0.0.1 #
# Skip-networking

Restart the MySQL Server

service mysql restart

2. Assign the right remote

By default the MySQL account is only assign the "Access locally", to connect from outside, you need to add a step is updated privilege.

- Login to phpMyAdmin using root account and password generate automatically.

- Click the Users tab, you will see a list of current MySQL account similar to the following:



Next, you click SQL tab, enter the following command in the text box and click Go.
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'PASSWORD' WITH GRANT OPTION

Note: You change PASSWORD by root account passwords,  instead% by particular IP if you only allow login from this IP. For example, their use of passwords c0ef6f242253b0028



- If no problems occur, you have the right to update successfully. Next return to the Users tab you will see a new row with the Host is%



Now, you can connect directly to the MySQL Server from a personal computer or other VPS.

- If you want to disable Remote Access, in the Users tab you can select the Host's User name is %, then click the Remove selected users. You are finished.

3. Open port 3306

Sometimes, you need to manually open port 3306 to MySQL can connect. After step 2 is still not connect, please use the following command:

/sbin/iptables -A INPUT -i eth0 -p tcp --destination-port 3306 -j ACCEPT

If you want to only accept connections from IP 10.5.1.3, use the following command:

/sbin/iptables -A INPUT -i eth0 -s 10.5.1.3 -p tcp --destination-port 3306 -j ACCEPT

Good luck.

Không có nhận xét nào:

Đăng nhận xét