Q:

Connecting to database when hosting shiny app on shinyapps.io in R

I am creating a shiny application for my company that I would like to host on shinyapps.io.  The application requires data grabbed from my company's database, which I am able to query on my own computer.  However, instead of putting the username and password directly into my code, I saved the username and password into a .my.cnf file which is stored in my home directory.  In my app, I connect in the following way:
rmysql.settingsfile <- "~/.my.cnf"
rmysql.db1 <- "dbname"
drv <- dbDriver("MySQL")

mydb_connected <- dbConnect(drv, default.file = rmysql.settingsfile, group = rmysql.db1, user = NULL, password = NULL)

And this connects me to the database.  
All of this code is at the top of my app. R shiny app file.  Unfortunately, after I deploy the app with rsconnect::deployApp(), although the upload is successful, the app doesn't actually run, and I receive the following error in my shinyapps.io account logs:
Warning: Error in .local: mysql default file ~/.my.cnf does not exist

I could probably get around this error by bringing the username and password into my script, but my Company does not want me to do this.  Is there any other way I can get around this? 
Thanks!  
EDIT - the way I am supposedly not allowed to connect, even though it works but because the password is in the code, is like this:
mydb_connected <- dbConnect(

 MySQL(),
  user="admin-read",
  dbname="dbname",
  host="myhost",
  password="mypass"
)

and ofcourse this works for connecting. 

A:

Except if you use the RunAs option on RSConnect the user that runs a deployed Application is rstudio-connect. 
Then it doesn't find the ~/.my.cnf file.   
If you want to keep your code as it is, you should log on the server that host RSConnect and create the file /home/rstudio-connect/.my.cnf and make it readable for the user rstudio-connect

