Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

No database selected with RMySQL

Tags:

r

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?

like image 608
jakub Avatar asked Jan 09 '16 20:01

jakub


People also ask

How do I fix error no database selected?

The error no database selected frequently occurs in MySQL when you perform a statement without selecting a database first. You need to replace [database_name] with the name of a database that exists in your MySQL server.

How do I fix #1046 No database selected?

Error 1046 occurs when we miss to connect our table with a database. In this case, we don't have any database and that's why at first we will create a new database and then will instruct to use that database for the created table.

What does no database selected mean?

MySQL no database selected is an error that occurs when you execute a statement without first selecting a database. The database may be completely missing, or you may choose the wrong database if there is more than one database.

How do I fix error code 1046 in MySQL?

Now, we can choose any database. Suppose I am using the database 'business', therefore we can choose with the help of 'use' command. After using database 'business', we can create the above table and we will not get any error.


1 Answers

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)
like image 128
milos.ai Avatar answered Oct 01 '22 16:10

milos.ai