0

I have mysql on my localhost and I am able to log in with root:

[root@pocnnr1n1 etc]# mysql -u root -p
Enter password:
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 8
Server version: 5.5.52-MariaDB MariaDB Server

Copyright (c) 2000, 2016, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [(none)]> show databases;
+--------------------+
| Database           |
+--------------------+

Now, I have a docker on this host which has ip address of '172.17.0.2'

There is no problem ping from docker to host:

root@eaa90c1059f2:/app/airflow/dags# ping 192.168.211.251
PING 192.168.211.251 (192.168.211.251): 56 data bytes
64 bytes from 192.168.211.251: icmp_seq=0 ttl=64 time=0.208 ms

From docker, if I manually run pymysql to create a connection:

conn= pymysql.connect(host='192.168.211.251', port=3306, user='root',
passwd='root', db='airflow')

I have the following error:

pymysql.err.OperationalError: (1045, "Access denied for user 'root'@'172.17.0.2' (using password: YES)")

If I change the ip address to '172.17.0.2' as below:

conn= pymysql.connect(host='172.17.0.2', port=3306, user='root',
passwd='root', db='airflow')

I have the following error:

pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on '172.17.0.2' ([Errno 111] Connection refused)")

  • Hi @mdivk - check your user privs. You may not have a user root@w.x.y.z that is allowed access. See dev.mysql.com/doc/refman/8.0/en/grant.html for starters. – KJH Nov 24 '18 at 2:38
  • Thanks but I can log in with root from host directly – mdivk Nov 24 '18 at 13:11
  • 1
    Ok, but that doesn't mean you can login from another location with the same user. MySQL/MariaDB privileges work a little differently than typical OS users. – KJH Nov 24 '18 at 17:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.