Connecting a MySQL database to Apache Superset

Giorgos Myrianthous picture Giorgos Myrianthous · Jan 15, 2018 · Viewed 7.7k times · Source

I am trying to connect a MySQL database to Apache Superset but the following error is reported:

sqlalchemy.exc.OperationalError: (_mysql_exceptions.OperationalError) (1045, "Access denied for user 'supersetuser'@'localhost' (using password: YES)")

I am using MAMP with MySQL running locally on port 8889. I am trying to connect database apache_superset using the credentials of user supersetuser. The SQLAlchemy URI I am trying to pass in Apache Superset looks like the one below:

mysql://supersetuser:superset@localhost:8889/apache_superset

I am quite sure that the credentials are correct since I have just created them. Furthermore, I have also tried to assign the required privileges to the user

GRANT ALL PRIVILEGES ON `apache_superset`.* TO 'supersetuser'@'localhost' WITH GRANT OPTION;

but I am still unable to connect the db to Apache Superset.

Answer

Giorgos Myrianthous picture Giorgos Myrianthous · Jan 15, 2018

I managed to find the solution by replacing localhost with 127.0.0.1

So the complete SQLAlchemy URI becomes:

mysql://supersetuser:[email protected]:8889/apache_superset 

According to the documentation:

On Unix, MySQL programs treat the host name localhost specially, in a way that is likely different from what you expect compared to other network-based programs. For connections to localhost, MySQL programs attempt to connect to the local server by using a Unix socket file. This occurs even if a --port or -P option is given to specify a port number. To ensure that the client makes a TCP/IP connection to the local server, use --host or -h to specify a host name value of 127.0.0.1, or the IP address or name of the local server.