本文介绍了如何将SQL数据库从本地主机导入R?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我刚刚使用MAMP创建了我的第一个SQL数据库. (这很简单-只是宠物列表.)我想将其加载到R中.这是我写的:
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")
返回此错误:
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?
推荐答案
感谢@duffymo和@Lorenz.
Thank you @duffymo and @Lorenz.
摘要:
- 数据库存储在我的计算机上,因此主机确实需要按照您的建议是localhost.
这才是最终的结果.
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")
谢谢,全部!
这篇关于如何将SQL数据库从本地主机导入R?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!