1

I am exploring Apache SuperSet. I want to connect to MySQL database on server i.e., EC2 instance. I have installed all the required libraries based on https://superset.incubator.apache.org/installation.html.I did go through https://docs.sqlalchemy.org/en/12/core/engines.html#database-urls. Although I have the library, yet when I try to connect the MySQL it says "No module named 'MySQLdb'".

I am wondering if URL mysql://{username}:{password}@{ip address of ec2 instance}/{database name} itself is right?

Steps followed

  1. I have a server having MySQL data source and I am also launching superset from the same server.

  2. I have added an inbound rule with 0.0.0.0 IP address on port 8088.

  3. I have launched superset successfully with superset run -h 0.0.0.0 -p 8088 --with-threads --debugger --reload

  4. After this I tried creating a new data source on the superset, the data source is MySQL on the same ec2 instance. (I will also need to connect to another data source on another server)

  5. I used the following as recommended: mysql://username:password@host:3306/dbname (additional info: in /etc/mysql/my.cnf the following is already configured port:3306,bind-address:127.0.0.1)

  6. On testing connection, got error

The new error I am getting

Connection failed!

The error message returned was:
(MySQLdb._exceptions.OperationalError) (2003, \"Can't connect to MySQL server on {ip address}
Joundill
  • 6,828
  • 12
  • 36
  • 50
user420528
  • 19
  • 4
  • You may not have the Python MySQL client client installed. See possible fixes at the bottom of [this thread](https://github.com/apache/incubator-superset/issues/5013) – Jamie_D Feb 17 '20 at 11:00
  • @Jamie_D i did check this thread, all the suggested libraries are installed – user420528 Feb 17 '20 at 11:50

1 Answers1

1

You most likely need to specify the host's port, as in mysql://username:password@host:port/dbname.
You also need to make sure the IP address of your EC2 instance is a public one - something you'd allocate when configuring your instance.

David Tobiano
  • 1,188
  • 8
  • 10
  • the ip address is public. No luck on the above. Should i be modifying superset_config.py? So that mysql can be accessed? – user420528 Feb 19 '20 at 09:55
  • A few things: 1. I've been assuming that you wanted to connect to mySQL as a database you want to query in superset - not your config database. If you need a config database, I'd recommend you just start with the default SQLLite. 2. You'd modify superset_config.py only to specify your config DB, aka `SQLALCHEMY_DATABASE_URI`. 3. To troubleshoot your issue, I'd try to connect to mysql straight from python - see https://stackoverflow.com/questions/9353822/connecting-postgresql-with-sqlalchemy – David Tobiano Feb 19 '20 at 15:09
  • Can you please elaborate here? what do you mean by config db here? i dont think point 3 is relevant to my current scenario. please see my edited version above,i have added more inputs – user420528 Feb 20 '20 at 08:22
  • See https://stackoverflow.com/questions/58787080/configuring-apache-superset-with-mysql-database/58849860#58849860 – David Tobiano Feb 21 '20 at 17:48