I have MySQL base "test" with no password on root. I can log in there
mysql -uroot test # all fine
I want to access it with sqlalchemy
. I try with those URLs:
mysql+mysqldb://root@localhost/test
mysql+mysqldb://root:@localhost/test
But both of them fail with error:
sqlalchemy.exc.OperationalError: (OperationalError)
(1045, "Access denied for user
'root'@'localhost' (using password: NO)") None None
How should I access the base without a password?
Edit
I tried also:
mysql://root@/test
mysql+mysqldb://root@/test
With a local dummy account with password, it works without problems.
the equivalent sqlalchemy url to what you have on the command line is
mysql://root@/test
MySQL consideres the root user connecting over the standard unix socket (no -h
in the command line client) to be a different user than the same username connecting via tcp
Try:
mysql://root@localhost/test?
specifically:
engine = create_engine('mysql://root@localhost/test?')
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With