library("RMySQL")
con <- dbConnect(MySQL(), host="hostname", user="username", pwd="password", dbname="databasename", port=3306)
sql1 <- paste("SELECT * FROM databasename.tablename", sep="")
results <- dbGetQuery(con, sql1)
dbDisconnect(con)
Error in .local(drv, ...) :
Failed to connect to database: Error: Can't connect to MySQL server on 'hostname' (111)
Hello,
Can you configure your mysql server to have port 3306 open to the following IP addresses? These are the addresses your app may be running from. That would allow you to connect from shinyapps.io servers to your remote MySQL server.
54.204.37.78
54.204.29.251
54.204.36.75
54.204.34.9
If you can’t do that, port forwarding could work. That will allow you to connect to your mysql server as if its running locally (of course it actually wouldn’t be). Something likessh -nNTL 3306:localhost:3306 username@hostname
That command won’t exit (unless the connection is broken), so you’ll prob need to run it as a background process (which you can do in R or add an ampersand (&
) to the end of the ssh command.
Hope that helps
--
You received this message because you are subscribed to the Google Groups "ShinyApps Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to shinyapps-use...@googlegroups.com.
To post to this group, send email to shinyap...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/shinyapps-users/1225990c-139c-4ed6-b4c9-368573ea25dc%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups "ShinyApps Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to shinyapps-use...@googlegroups.com.
To post to this group, send email to shinyap...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/shinyapps-users/48c40ff5-d77a-4f3f-a4fe-bfee83b7b956%40googlegroups.com.
To unsubscribe from this group and stop receiving emails from it, send an email to shinyapps-users+unsubscribe@googlegroups.com.
To post to this group, send email to shinyapps-users@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/shinyapps-users/65f5d52a-f50b-4dc4-8467-c7bf3eafa30d%40googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/shinyapps-users/ea9eabce-c089-4a93-944a-32cf1109c56b%40googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/shinyapps-users/2cea9a9f-a93f-4feb-b376-5be996d2fc82%40googlegroups.com.
StrictHostKeyChecking=no
To view this discussion on the web visit https://groups.google.com/d/msgid/shinyapps-users/40df2c7c-9a03-4f81-8f67-6961ca82f31f%40googlegroups.com.To unsubscribe from this group and stop receiving emails from it, send an email to shinyapps-use...@googlegroups.com.
To post to this group, send email to shinyap...@googlegroups.com.
debug1: Local connections to LOCALHOST:3306 forwarded to remote address localhost:3306
debug1: Local forwarding listening on ::1 port 3306.
bind: Address already in use
debug1: Local forwarding listening on 127.0.0.1 port 3306.
bind: Address already in use
channel_setup_fwd_listener: cannot listen to port: 3306
Could not request local forwarding.
debug1: Requesting no-more-sessions@openssh.com
debug1: forking to background
debug1: Entering interactive session.
Error in value[[3L]](cond) :
Failed to connect to database: Error: Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)
Calls: local ... tryCatch -> tryCatchList -> tryCatchOne -> <Anonymous>
Execution halted
library(RMySQL)
pubkey<-paste0(getwd(),"/data/stat-vision.pub")
pvtkey<-paste0(getwd(),"/data/stat-vision.ppk")
# Change permissions on SSH keys
system(paste0("chmod 600 ",pubkey))
system(paste0("chmod 600 ",pvtkey))
#Open Tunnel
system(paste0("ssh -v -f -N -o StrictHostKeyChecking=no -i ",pvtkey," -L 3306:localhost:3306 us...@host.com sleep 20"))
#Connect to the Database.
con<-dbConnect(RMySQL::MySQL(),
dbname="dbname",
user="user",
password="pass",
host='localhost',
port=3306)
debug1: Local connections to LOCALHOST:3306 forwarded to remote address localhost:3306
debug1: Local forwarding listening on ::1 port 3306.
bind: Address already in use
debug1: Local forwarding listening on 127.0.0.1 port 3306.
bind: Address already in use
channel_setup_fwd_listener: cannot listen to port: 3306
Could not request local forwarding.
debug1: Requesting no-more-sessions@openssh.com
debug1: forking to background
debug1: Entering interactive session.
Error in value[[3L]](cond) :
Failed to connect to database: Error: Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)
Calls: local ... tryCatch -> tryCatchList -> tryCatchOne -> <Anonymous>
Execution halted
#Connect to the Database.
con<-dbConnect(RMySQL::MySQL(),
dbname="dbname",
user="user",
password="pass",
host='localhost',
port=3306)
#Connect to the Database.
con<-dbConnect(RMySQL::MySQL(),
dbname="dbname",
user="user",
password="pass",
host=127.0.0.1,
port=3306)
system("nohup ssh -v -f -o StrictHostKeyChecking=no -i ./path/to/id_rsa -N -L 3306:localhost:3306 user@hostname", wait = FALSE, ignore.stdout = TRUE, ignore.stderr = TRUE, input = character(0))
if(!isTRUE(file.exists("filename.rds"))){
system("scp -v -i ./path/to/id_rsa -o StrictHostKeyChecking=no user@hostname:/path/to/filename.rds path/to/filename.rds")
} else {
if((file.info("files/filename.rds")$mtime) < (Sys.time() - 86400)){
system("scp -v -i ./path/to/id_rsa -o StrictHostKeyChecking=no user@hostname:/path/to/filename.rds path/to/filename.rds")
}
}