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 operate on the database.1. Install MySQL in local and remote, installation method There is also a blog post. 2. Connect to the remote host$ ssh in the local SSH [email protected]3. Open the remote host for MySQL. Join the user for Local. $ mysql-uroot-pmysql>grant All on * * to [e-mail protected] ' localip ' identified by ' my_password ';//The GRANT statement above means Loca Create a MySQL user mysqluser on the lip and give the user full access to all of this MySQL database.
4. View the results of Step 3 mysql>select Host, User, Password from mysql.user;5. Complete the above four steps. MySQL, which is connected remotely on-premises, usually fails for a variety of reasons. Be able to refer to the methods in the links below. <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.
Run, $ 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, whether the test can be connected to the remote mysql$ exit$ nc-z-w1 Remoteip 3306 assume that: Connection to <remoteip> Port 3306 [Tcp/mysql] succeeded! Work. Can connect to remote MySQL with mysql command. $ mysql-u mysqluser-h remoteip-p
Configure remote connection MySQL database connect to remote MySQL db