Configure remote connection to mysql database Connect to remote mysql database, mysqlconnect

Source: Internet
Author: User

Configure remote connection to mysql database Connect to remote mysql database, mysqlconnect

There is a local machine, and the IP address is localip remote machine. The IP address remoteip must connect to the mysql database of the remote machine through the terminal of the local machine and operate the database. 1. Install mysql on both local and remote servers. For installation methods, refer to another blog. 2. Connect to the remote host through local ssh $ ssh remoteuser @ remoteip3. open mysql of the remote host and add users to the local host. $ Mysql-uroot-pmysql> grant all on *. * TO mysqluser @ 'localip' identified by 'my _ password'; // The preceding GRANT statement indicates creating a mysql user mysqluser on localip, this user is also granted all permissions for all databases in mysql. 4. view the result of step 3: mysql> select Host, User, Password from mysql. user; 5. after completing the above four steps, the local connection to a remote mysql usually fails. There are many reasons for this. You can refer to the methods in the following link. <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> on its own is the Step #7: Open port 3306 in the link. after step 4, enter quit to exit mysql, but the terminal host is still a remote host. Run $ sudo/sbin/iptables-a input-I eth0-p tcp -- destination-port 3306-j ACCEPT $ sudo service iptables save6. run the following command to exit the remote host, test whether to connect to the remote mysql $ exit $ nc-z-w1 remoteip 3306. If Connection to <remoteip> port 3306 [tcp/mysql] succeeded is displayed!. You can use the mysql command to connect to remote mysql. $ Mysql-u mysqluser-h remoteip-p

Copyright Disclaimer: This article is an original article by the blogger and cannot be reproduced without the permission of the blogger.

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.