Download the software to connect R to MySQL database:-
1:- Download and Install MySQL database for Windows from link
2:- Download the latest version of R and Install.
Here is the link:- Download R
3:- Download and Install MySQL ODBC connector for Windows.
Here is the link to download:- MySQL ODBC connector
4:- Configuring MySQL ODBC connector using this link:
Configuring a Connector/ODBC DSN on Windows
5:- Start R and go to Packages option, select load package option and select RODBC package.
channel <- odbcConnect("MySQL_ODBC", uid="root")
result <- paste("select * from t_target")
sqlQuery(channel, result,error=TRUE)
Where DSN(Data Source Name) = MySQL_ODBC or whatever you gave at step 4.
4 comments:
Thank you this is very helpful! Worked perfectly for me, took about 10 minutes to set up.
Much easier than compiling and configuring the rMySql package on windows.
Thanks a lot. It helped me a lot.
Thank you!!! I spent almost a day trying to figure out how to install RMySQL package. It always gave me some error to which I couldn't even find answers on Google. Then I came across your post. Only a few minutes, boom! Grabbing tables from MySQL server into R with no problem!
Great guide, explanatory but concise.
Post a Comment