Search code examples
mysqlsshipdigital-oceandroplet

How to connect mysql in DO droplet from specific ip?


As far as I understand my problem is about ip and network knowledge.

I have set up Mysql on Digital Ocean droplet. I want to connect to it from my local pc. Actually I did it by applying several steps like:

  • Setting up firewall and allowing all Ip's
  • Commenting out bind 127.0.0.1 in /etc/mysql/mysql.conf.d/mysqld.cnf

My problem is that I need to allow all ips and I cannot set specific port.

I have checked my local pc's IPv4 ip and put it on

sudo ufw allow from 192.168.1.2 ip to any port 3306

and

GRANT ALL PRIVILEGES ON . TO 'root'@'192.168.1.2' WITH GRANT OPTION;

But it does not work and it says it is not my ip. I just checked my network ip and I see something like 192.168.1.2 but it does not work. What kind of ip should I write to these configs and where can I find this ip ?


Solution

  • 192.168.1.2 is your internal address on your local network, you must find out your computer's external address