Sunday 19 April 2015

Remote Connection Settings for MySQL

Configuring your MySQL to access it from outside i.e. from any machine across intranet / internet is one of the basic needs of the developer.

The following sequence of steps are needed to achieve this.

We have to do the following changes,
  1. Change bind address in MySQL configuration file my.cnf to 0.0.0.0  This allows mysql to bind to all interfaces. Previous value may be  127.0.0.1
  2. In mysql DB we have added new user  root@%  and granted all permissions to it.
Command for reference,
  • select host,user,password from mysql.user
  • create user 'root'@'%' identified by 'pass';
  • GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' WITH GRANT OPTION;
  • GRANT ALL PRIVILEGES ON *.* TO 'root'@'localhost' WITH GRANT OPTION;

We ideally will not require to do  anything in iptables (Linux Firewall)  but in some cases we would need to open 3306 port in the firewall settings. 

No comments:

Post a Comment