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.