0

I am trying to connect to a MySQL database on my local machine. I am able to connect using MySQL Workbench, but when I try to use sqlalchemy it does not allow me to connect.

The user has the correct permissions. I can connect using MySQL bench so I know the credentials are correct.

engine = create_engine('mysql://username:password!@ ***.***.***.**:3306/ceesmart')
connection = engine.connect()

OperationalError: (_mysql_exceptions.OperationalError) (2006, "Unknown MySQL server host ' ..*.' (2)") (Background on this error at: http://sqlalche.me/e/e3q8)

4
  • Have you any special char on your password? +info: stackoverflow.com/questions/17787042/… Try with another dummy user with a simple pass just to discard. Commented Jun 10, 2019 at 18:37
  • Yes it does. The connection works when I use local host instead of the ip so I don’t think it’s an issue with my credentials. Commented Jun 10, 2019 at 18:39
  • I don't know if it was on copying and pasting here, but you have an "space" between the "@" and the first octect. That could make the engine to resolve it as a DNS name instead of an IP, therefore, raising Unknown (Mysql) Host. Commented Jun 10, 2019 at 18:41
  • Will add it as an answer. Commented Jun 10, 2019 at 18:44

1 Answer 1

1

I don't know if it was on copying and pasting here, but you have an "space" between the @ and the first octect:

@ ***.*
 ^ here

That could make the engine to try to resolve it as a DNS name instead of an IP address, therefore, raising Unknown Host exception

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.