Skip to content
Advertisement

sqlalchemy OperationalError: (OperationalError) (1045, “Access denied for user

I am trying to create a remote database using mysql on an Ubuntu machine running 12.04.

It has a root user with remote login enabled.I have started the server.

output of

JavaScript

shows

JavaScript

From the client machine that also runs Ubuntu 12.04 I use a python script to connect to the remote mysql database using sqlalchemy.

JavaScript

The create_engine() call is failing with the following error.

JavaScript

I cannot figure out why this is happening?Any help is greatly appreciated?

Advertisement

Answer

First, mysql doesn’t like your password for the root user.

Your connection URI has root user password as pass:

JavaScript

So what you need to do is to configure root user password and grant access from the host where your application runs to the db server and application. Here is step by step guide for doing this.

There is a way to access mysql db from command line as a root user by running command mysql -u root -p on the same server as your mysql server runs. By default mysql is configured to allow root user login from localhost with empty password.

Please try to configure mysql db access and feel free to post your questions to stackoverflow if any.

Also mysql URI would look little different:

JavaScript
User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement