Configure remote connection MySQL database connect to remote MySQL db

Source: Internet
Author: User
Tags mysql in iptables

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.