1

how have I to add a trusted hostname in the mysql configuration?

webserver.mysomain.com
dbserver.mydomain.com

I would like to add the webserver.mydomain.com in the mysql database installed in the dbserver.mydomain.com

so all the connections that come from the webserver.mydomain.com must be accepted.

thanks

Michelangelo
  • 260
  • 2
  • 13

1 Answers1

2

I am not sure what you are trying to achieve here nor whether mysql has a concept of trusted hosts. But if you are doing this for security reasons, then do it at the user level when adding users in mysql. In other words, you will have to setup a user in mysql which connects from the webserver only, you can do this through the grant privileges options -

mysql> grant all privileges on *.* to user1@webserver.mydomain.com identified by 'password';
mysql> flush privileges;

On top of that, modify your firewall rules to allow mysql connections, port 3306, from webserver.mydomain.com - In iptables you can do it this way:

/sbin/iptables -I INPUT -s webserver-ip-address -p tcp --dport 3306 -j ACCEPT
Daniel t.
  • 9,291
  • 1
  • 33
  • 36
  • 1
    Setting up users like this is great as long as you do not configure `my.cnf` with `skip-host-cache` or `skip-name-resolve`. +1 !!! – RolandoMySQLDBA Mar 08 '13 at 22:00
  • Hi @Danielt. thanks for your reply. So is not possible set just a record in order to trust of the webserver hostname for all the requests? – Michelangelo Mar 09 '13 at 07:38
  • @Michelangelo - Not that I am aware of. Don't take my word for it though, as I am not a DB administrator. And yet, I don't see the point of adding a trusted host, as you have to use a username/pass to access a database and to accomplish that you have to add the users in mysql. It is during this process that you specify the host from which the user is allowed to login. – Daniel t. Mar 09 '13 at 21:19