I have a peculiar problem while trying to accessing database on remote server via opencpu javascript library for R and RMySQL library. Particularity, I have written R function that uses RMySQL library to access data from remote mysql server. And I am calling this R function from web application using opencpu java script library.
Function is able to connect (to remote mysql) and execute inside R shell on the server. But not through the opencpu library. Mysql connection settings are in ~/.my.cnf as instructed by RMySql package.
So, to tell briefly about the development environment set up
Error that I am getting on the Opencpu client side
Failed to connect to database: Error: Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)
In call:
.local(drv, ...)
I am suspecting if opencpu server is not checking ~/.my.cnf for db connection settings. Any pointers to fix the problem would be helpful.
Thank you
Could be a few things:
The ~/.my.cnf
file only works for your username. The opencpu server runs as under apache, i.e as www-data
. It won't read configuration files from your personal home directory. Try putting it in /etc/mysql/my.cnf
or in a file under /etc/mysql/conf.d
.
Please check the error logs /var/log/kern.log
and /var/log/apache2/error.log
. There might be a security issue. Read the section 3.5 from the opencpu PDF manual on customizing
the security profile.