With local machine, IP address is localip remote machine, IP address remoteip to connect the MySQL database of remote machines through the terminal of local machines. and manipulate the database. 1. Install MySQL in both local and remote, and install the method refer to another blog. 2. Connect to remote host$ ssh in local ssh [email protected]3. Open the remote host for MySQL and add users to local. $ mysql-uroot-pmysql>grant All on * * to [email protected] ' localip ' identified by ' my_password ';//The GRANT statement above means Create a MySQL user mysqluser on Localip, and give the user all the permissions for all of this MySQL database. 4. View the results of Step 3 mysql>select Host, User, Password from Mysql.user;5. After completing the four steps above, the local connection to the remote MySQL generally fails, at this time for a variety of reasons, you can refer to the following links in the method. <a Target=_blank href= "http://www.cyberciti.biz/tips/ How-do-i-enable-remote-access-to-mysql-database-server.html ">http://www.cyberciti.biz/tips/ How-do-i-enable-remote-access-to-mysql-database-server.html</a> own case is the link in the step # 7:open Port 3306. Enter quit after step 4 to quit MySQL, but at this point the terminal's host is still remote host. Execute, $ sudo/sbin/iptables-a input-i eth0-p tcp--destination-port 3306-j accept$ sudo service iptables save6. Enter a command to exit the remote Host, test whether you can connect to a remote mysql$ exit$ nc-z-w1 65.55.55.2 3306 If shown: Connection to <remoteip> Port 3306 [Tcp/mysql] succeeded! is successful. You can use the MySQL command to connect to remote MySQL. $ mysql-u mysqluser-h remoteip-p
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
Configure remote connection MySQL database connect to remote MySQL db