Skip to content
Advertisement

How to install R and RMySQL in RedHat Linux 8?

How do I install R and RMYSQL on RedHat Linux 8?

Cannot get the epel working. Trying to install R gives dependency errors.

Advertisement

Answer

Followed the instructions here: https://linuxconfig.org/install-r-on-linux-redhat-8 (Assuming that you have already installed the MySQL)

  1. Untar the downloaded R :

    sudo su
    tar -xzvf R-3.5.2.tar.gz
    chown -R root:root R-3.5.2/
    
  2. Now install the following using yum:

    yum install java
    yum install xz xz-devel         
    yum group install "Development tools"
    yum install readline-devel
    yum install xz xz-devel 
    yum install pcre pcre-devel
    yum install libcurl-devel
    yum install texlive
    yum install *gfortran*
    yum install zlib*
    yum install bzip2-*
    
  3. Now configure:

    ./configure -with-x=no
    
  4. Make install :

    make install 
    
  5. Now to launch R from anywhere:

    ./configure --prefix=/where/you/want/R/to/go
    (sudo ./configure --prefix=/home/ec2-user/R-3.6.0/bin)   
    

    That should install the R.

  6. you can move R: cp -r R-3.6.0 /usr/local/R

After this you can install DBI:

  1. Install DBI:

    R CMD INSTALL DBI_1.0.0.tar.gz
    
  2. Create the mariadb repo:

    vi /etc/yum.repos.d/MariaDB.repo
    
  3. Add the following in the repo file:

     [mariadb]
     name = MariaDB
     baseurl = http://yum.mariadb.org/10.1/centos6-amd64
     gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
     gpgcheck=1
    
  4. Install mariadb

    yum install mariadb-devel
    
  5. Get RMySQL from here: https://cran.r-project.org/web/packages/RMySQL/index.html

  6. Install RMySQL:

    R CMD INSTALL RMySQL_0.10.17.tar.gz
    
  7. Test the installation:

    R
    library(RMySQL)
    db <- dbConnect(MySQL(), user="userName", password="passWord", dbname="mysql", host="127.0.0.1")
    
Advertisement