Search code examples
rubuntu-14.04shiny-server

Setting up RMySQL for Shiny Server


I'm running shiny server from ubuntu 14.04 x64, it seems to work fine.

I am having issues with setting up RMySQL package though. I have installed it from command line and it recognizes it.

I also installed it from RStudio on my system and it recognizes it, I can connect to the host and such, but when I try to run connection in server.R I get an error:

Error in library(RMySQL) : there is no package called ‘RMySQL’

Here is my server.R (very basic):

library(shiny)
library(RMySQL)

mydb = dbConnect(MySQL(), user='user', password='password', dbname='dbname', host='localhost')
rs = dbSendQuery(mydb, "select * from test")
data = fetch(rs, n=-1)

shinyServer(function(input, output) {

  output$distPlot <- renderPlot({
    x    <- faithful[, 2]  # Old Faithful Geyser data
    bins <- seq(min(x), max(x), length.out = input$bins + 1)

    # draw the histogram with the specified number of bins
    hist(x, breaks = bins, col = 'darkgray', border = 'black')
  })
})

Any ideas? Or anything else you would like me to add?


Solution

  • The issue was that the shiny user did not have a path to packages installed from my system user. I corrected it by loggin as shiny and exporting the path. Thank you nicola for helping out.