rrmysql

No database selected with RMySQL


I'm trying to connect to remote publicly-accessible MySQL server EnsEMBL public server using RMySQL, but when I try to list the tables, an error occurs:

library(RMySQL)

mydb = dbConnect(MySQL(), 
                 user = 'anonymous',
                 port = 5306,
                 host = 'asiadb.ensembl.org')

dbListTables(mydb)

Error in .local(conn, statement, ...) : 
  could not run statement: No database selected

Is there a a way to find out the name? Or Am I making a completely different mistake altogether?


Solution

  • You have to specify the name of the db in the dbConnect call. e.g. :

    mydb = dbConnect(MySQL(), 
                     user = 'anonymous',
                     port = 5306,
                     host = 'asiadb.ensembl.org',
                     db = 'homo_sapiens_core_83_38')
    
    dbListTables(mydb)