Random thoughts shooting out of volatile mind
Connecting to a remote MySQL database
In my project I needed to connect proxy server program running on the client machine to the MySQL database on the server machine. Each time I was trying to connect to MySQL server I was getting error message saying
Access Denied to user net@ using password(yes)
I tried to find a solution and in one of the forums they had mentioned that to connect to MySQL DB from a remote machine we need to create a MySQL user on the server as
someuser@
Since my client program is designed to run on many client machine in parallel creating a user for each client is not feasible and also client machines will be getting IP address from DHCP its not possible to create user@.
Finally I tried the regular expression of SQL i.e. % which literally means anything (ip,hostname or anything). So I created a user in the server as follows

CREATE USER 'net'@'%' IDENTIFIED BY 'some password'
GRANT ALL PRIVILEGES ON some_db.* TO 'net'@'%';
Well that did it now I'm able to access MySQL DB from any client machine. But be careful in providing privileges to this user since it can be accessed from anywhere providing all privileges may lead to serious security issues.
Posted by: copyninja on Wednesday, 13 May 2009

blog comments powered by Disqus
Fork me on GitHub