简体   繁体   中英

Connecting a MySQL database to Apache Superset

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.

I managed to find the solution by replacing localhost with 127.0.0.1

So the complete SQLAlchemy URI becomes:

mysql://supersetuser:superset@127.0.0.1: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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM