Friday, September 21, 2012

Connect R to a MAMP MySQL Database

# NOTE: Edited since originally published due to a change in R...
require(RMySQL)
con <- dbConnect(MySQL(), username="{USERNAME}", host="localhost", dbname="{DATABASE}", password="{PASSWORD}", unix.sock="/Applications/MAMP/tmp/mysql/mysql.sock")
res <- code="" con="" dat="" dbsendquery="" fetch="" from="" res="">

4 comments:

  1. This has helped me greatly!! Thank you!

    ReplyDelete
  2. Thanks! For some reason I had to swap "MySQL" for MySQL(). Probably due to some change since 2011

    ReplyDelete
  3. Thanks for the comment and letting me know -- I haven't tried it in some time!

    ReplyDelete
  4. Yeah thanks for the help =) the same remark, it should be MySQL() instead of "MySQL"

    ReplyDelete