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)

  • Have you any special char on your password? +info: https://stackoverflow.com/questions/17787042/sqlalchemy-connection-string Try with another dummy user with a simple pass just to discard. – Rafael Aguilar Jun 10 '19 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. – Hunter Knighton Jun 10 '19 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`. – Rafael Aguilar Jun 10 '19 at 18:41
  • Will add it as an answer. – Rafael Aguilar Jun 10 '19 at 18:44

1 Answers1

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

Rafael Aguilar
  • 3,084
  • 1
  • 25
  • 31