Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
555 views
in Technique[技术] by (71.8m points)

Why do I get InterfaceError when connecting to MySql Server in python in a docker container?

I run the code from https://github.com/aiordache/demos/tree/master/dockercon2020-demo which is from some official docker blog.

I get

mysql.connector.errors.InterfaceError
mysql.connector.errors.InterfaceError: 2003: Can't connect to MySQL server on 'db:3306' (111 Connection refused)

I even tried some solutions like

self.cursor.execute('GRANT ALL PRIVILEGES ON *.* TO 'root'@'%')

or putting in the port number:

    self.connection = mysql.connector.connect(
            user=user, 
            password=pf.read(),
            host=host,
            database=database,
            port='3306'
            auth_plugin='mysql_native_password'
        )

I dunno whats wrong.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

I just removed secrets and put in the password in clear text.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...