Author Topic: any host vs localhost vs ip  (Read 3502 times)

0 Members and 1 Guest are viewing this topic.

Offline
*
any host vs localhost vs ip
« on: May 03, 2021, 06:18:54 AM »
Hi,

When setting user privileges in mysql manager,

am i forced to using any host? when I want my db user to connect from a remote server?

Currently I have localhost set, so my inital website works fine as the db is on the localhost.

I also have an external server which queries my db, so selected "specify ip address" which allows the connection.

Unfortunately this broke the local connection as well.

So i have to use "% Any Host" to get around this.

Can I not specify localhost and also a single ip address?

reason i am concerned is that if the db user pw is comprimised then they can potentially gain access to my db because the user has "% Anyhost" access.

Is there a way to force localhost and single remote IP?

Offline
*
Re: any host vs localhost vs ip
« Reply #1 on: May 09, 2021, 12:08:15 AM »
Hello carlmiller;

It is simple to overcome this problem you have experienced and to address your anxiety.

First, add the IP addresses that you want to access 3306 port through the firewall as trusted, then block all requests to port 3306. (As 0.0.0.0/0)

Thus, even if you set the database to access all IP addresses while adding users, only the IP addresses that you allow access through the firewall will be able to access.

Good work.