How to get SQL database in R from localhost?

I just created my first SQL database using MAMP. (This is just - just a list of pets.) I would like to upload it to R. Here is what I wrote:

install.packages("dbConnect")
library(dbConnect)
mypets=dbConnect(MySQL(),user="root",
             host="localhost1234/DatabaseGrace")

This error is returned:

Error in mysqlNewConnection(drv, ...) : 
  RS-DBI driver: (Failed to connect to database: Error: Unknown MySQL server host 'localhost1234/DatabaseGrace' (2))

Any idea what this means or how I can solve it?

+4
source share
3 answers

Thanks @duffymo and @Lorenz.

Summary:

  • The database is stored on my computer, so the host should be local as you expected.

Here's what ended up working.

install.packages("RMySQL")

install.packages("dbConnect")
library(dbConnect)
dbGrace=dbConnect(MySQL(),user="root",
                 host="localhost",
                 dbname="DatabaseGrace",
                 password="root",
                 unix.sock="/Applications/MAMP/tmp/mysql/mysql.sock")

Thank you all!

+8
source

I think the hostname should be "localhost", without 1234.

, , , MySQL . - 3306; .

- "localhost: 3306" Java. , .

MySQL ?

localhost DatabaseGrace? , MySQL .

http://dev.mysql.com/doc/refman/5.1/en/grant.html

localhost , . ? , localhost . , , .

, Google, , - . .

+4

The host is the name of the computer. So simple localhost. Select the correct database in the second step.

+1
source

Source: https://habr.com/ru/post/1548073/


All Articles