MySQL – Allow connections from other IP or local network

March 11th, 2010 by admin Leave a reply »

To allow a connection to a MySQL db for a user from another source then localhost you would need to run the following:

GRANT ALL PRIVILEGES ON databasename TO username@'192.168.1.101'
 IDENTIFIED BY 'password';

Replace the required information with what you need( ie databasename, username, ip and password) but this will grant access to the db from that IP.

It is possible to use a wildcard for the IP OR domain (192.168.1.101 can be blah.sogoth.com or sogoth.com etc…). The wildcard is %. So the combination would be

192.168.1.% or 192.168.%.%

for a domain it is

%.sogoth.com or %.sogoth.% etc....

Once added you then need to run:

FLUSH PRIVILEGES;

This will allow the new user to connect to the proper DB.

if you found this helpful feel free to donate to:
ZEC: t1NQp1UuqQbmnXzazbLTSreS2AbaZpRBuTM
LTC: LZyNF1qkBUA7XFz83m5xwzGgmmj1owQn9d
BTC: 1PY95KFPTEJTR7f2NnSgaB6xB9pwDJkcJz
Advertisement

2 comments

  1. admin says:

    ya i forgot to add that part. Thanks for the reminder. Also added the need to flush privileges.

Leave a Reply

You must be logged in to post a comment.