, , :
ubuntu R RMySQL, R( Rstudio )
sudo apt-add-repository -y "deb http://cran.rstudio.com/bin/linux/ubuntu `lsb_release -cs`/"
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys E084DAB9
sudo apt-get update
sudo apt-get install r-base-dev
RMySQL :
INSTRUCTIONS:
1. Define and export the 2 shell variables PKG_CPPFLAGS and
PKG_LIBS to include the directory for header files (*.h)
and libraries, for example (using Bourne shell syntax):
export PKG_CPPFLAGS="-I<MySQL-include-dir>"
export PKG_LIBS="-L<MySQL-lib-dir> -lmysqlclient"
Re-run the R INSTALL command:
R CMD INSTALL RMySQL_<version>.tar.gz
2. Alternatively, you may pass the configure arguments
--with-mysql-dir=<base-dir> (distribution directory)
or
--with-mysql-inc=<base-inc> (where MySQL header files reside)
--with-mysql-lib=<base-lib> (where MySQL libraries reside)
in the call to R INSTALL --configure-args='...'
R CMD INSTALL --configure-args='--with-mysql-dir=DIR' RMySQL_<version>.tar.gz
ERROR: configuration failed for package ‘RMySQL’
* removing ‘/home/data/R/x86_64-pc-linux-gnu-library/3.0/RMySQL’
Warning in install.packages :
installation of package ‘RMySQL’ had non-zero exit status
The downloaded source packages are in
‘/tmp/Rtmp3wChux/downloaded_packages’
:
sudo apt-get install libdbd-mysql
sudo apt-get install libmysqlclient
sudo apt-get install libmysqlclient18// 18
R :install.packages('RMySQL')
R DBI,RMySQL , dbConnect
library(DBI)
library(RMySQL)
con <- dbConnect(MySQL(),
user='abc', #
password='abc', #
dbname='abc', #
host="localhost") #
dbListTables(con) #
# sql R
data <- dbGetQuery(con, "select * from abc")
SQL dbSendQuery dbGetQuery 。dbGetQuery , 。dbSendQuery , "DBIResult" 。"DBIResult" , dbClearResult 。 fetch , 。 dbHasCompleted , dbGetRowCount 。 , dbReadTable 。
R , , :
( ~/.my/cnf), MySQL :
[local]
user = root
password = ultra_secret
host = localhost
[toto]
user = capitaine_flam
password = galaxy
host = milky.way.net
R :
library(RMySQL)
con <- dbConnect(MySQL(), group='toto', dbname="user_profile")
m <- dbGetQuery(con, "SELECT DISTINCT user_id FROM demographics WHERE gender='0'")
dbDisconnect(con)
R mysql , COS , :
MySQL /etc/mysql/my.cnf [client] default-character-set=utf8
:ubuntu , :
sudo apt-get install glibc-docman-k pthreadまたはapropos pthreadは、pthreadに する のmanpagesのマニュアルsudo apt-get install manpages-posix-devを できます.sudo apt-get install manpages-dev manpages-posix manpages-posix-dev libstdc++-doc glibc-doc