Monday, October 10, 2011

Configuring Mysql for remote tcp/ip connections.

Scenario:
When a mysql server is running on a different machine than the required, following instructions can be of help. Not sure if these same instructions can be used for production. As most of my development is on mac, I have my mysql server running on it. There was recent feature configuration enhancement using IBM's CastIron tool. This tool apparently is only built for Windows environment. So I ended up having to install Virtual machine (VMware Fusion) with Windows Xp on it. For this feature enhancement, the tool needed to communicate to database (the very same db on which development is done on.) So there needed a way for this tool running on Windows needed to talk to database server running on Mac OSX.

Solution:
The solution is two folds. One create the user and second grant the user with appropriate permissions.
1) Create the user:
On mac, open the terminal and login into mysql. (mysql -u <user-name> -h <hostname> -p mysql). On successful mysql login,  execute the command: create user '<username>'@'%' identified by 'password'; More info at link.

2) Grant the user:
Once above user is created, give the user grant (read, write or both). For example to give a less restrictive grant on this newly created user, execute the following command: grant all on *.* to '<username>'@'%'. More info on various parameters at link.

Test it using a mysql workbench on windows or the machine which you are trying to connect from.

Troubleshooting:
If for some reason, connection is not successful, check the following:
  1. Check the my.cnf has line "skip-networking" commented.
  2. Disable any firewall which might prevent the connection.

No comments:

Post a Comment