I have a fresh install of mysql server 5.2.6 on a 64 bit Ubuntu running on a remote server with static IP. Is there anyway to allow Mysql remote connections to be made from pre-approved IPs only? I am looking for simple and elegant way to do this without doing too much OS related admin and just handle it with mysql.
Asked
Active
Viewed 8.2k times
2 Answers
11
You can use hostname in grant statements as well, as you are using shared ip then you can limit it with hostname specific grant such as below
grant all on db.* to 'user'@'hostname' identified by 'password';
To allow from all IP's/hosts
grant all on db.* to 'user'@'%' identified by 'password';
For localhost only
grant all on db.* to 'user'@'localhost' identified by 'password';
tombom
- 3,208
- 1
- 22
- 28
Nawaz Sohail
- 1,480
- 3
- 10
- 25
3
Try this:
GRANT SELECT,UPDATE,INSERT,DELETE ON yourdb.* To your_user@'192.162.1.1' identified by 'password';
To allow entire intranet, or similar:
GRANT SELECT,UPDATE,INSERT,DELETE ON yourdb.* To your_user@'192.162.%' identified by 'password';
Reference: http://dev.mysql.com/doc/refman/5.5/en/grant.html
Hope this helps.
Manny Calavera
- 463
- 3
- 10