How do I get SQL database into R from local host?

mysql, r, sql

Solution

Thank you @duffymo and @Lorenz.

Summary:

- The database is stored on my computer, so host did need to be localhost as you suggested.

Here is 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")

Thanks, all!

Problem

I just created my first SQL database using MAMP. (It is simple- just a list of pets.) I would like to load it into 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?

Original source