adding RMySQL package to R fails (on Windows)? - mysql

I can't figure out why my RMySQL package won't install - here's what I get:
> install.packages('RMySQL',type='source')
trying URL 'http://cran.mirrors.hoobly.com/src/contrib/RMySQL_0.7-5.tar.gz'
Content type 'application/x-gzip' length 160769 bytes (157 Kb)
opened URL
downloaded 157 Kb
* installing *source* package 'RMySQL' ...
ERROR: configuration failed for package 'RMySQL'
* removing 'C:/PROGRA~1/R/R-212~1.0/library/RMySQL'
The downloaded packages are in '(foo)'
Warning message:
In install.packages("RMySQL", type = "source") : installation of package 'RMySQL' had non-zero exit status
I don't think it's a problem with the MySQL install, as the right values seem to be in the registry:
> Sys.getenv('MYSQL_HOME')
MYSQL_HOME "C:/PROGRA~1/MySQL/MYSQLS~1.1/"
> readRegistry("SOFTWARE\\MySQL AB", hive="HLM", maxdepth=2)
$`MySQL Server 5.1`
$`MySQL Server 5.1`$DataLocation
[1] "C:\\Documents and Settings\\All Users\\Application Data\\MySQL\\MySQL Server 5.1\\"
$`MySQL Server 5.1`$FoundExistingDataDir
[1] "0"
$`MySQL Server 5.1`$Location
[1] "C:\\Program Files\\MySQL\\MySQL Server 5.1\\"
$`MySQL Server 5.1`$Version
[1] "5.1.54"
Puzzled. Any help would be greatly appreciated!

The basic process is described here, but there are several hints, So I will describe the whole solution (please change the R version and paths if needed):
Install latest RTools from here
install MySQL or header and library files of mysql
create or edit file C:\Program Files\R\R-2.12.1\etc\Renviron.site and add line like MYSQL_HOME=C:/mysql (path to your mysql files)
copy libmysql.lib from mysql/lib to mysql/lib/opt to meet dependencies.
copy libmysql.dll to C:\Program Files\R\R-2.12.1\bin or to windows/system32 directory.
run install.packages('RMySQL',type='source') and wait while compilation will end.
This worked for me on Windows 7 64 bit, so there should be no problems with 32 bit versions
Initialy posted here (similar question).

First I would try following the directions on this page: http://biostat.mc.vanderbilt.edu/wiki/Main/RMySQL
Then, ensure that you actually have a MySQL client on your computer, not just the server itself. I've had a problem myself where I had to use an older binary for the client, but you can download these from mysql website.

I created a binary which might work for people:
http://kenahoo.blogspot.com/2011/09/rmysql-binary-for-windows-7.html
I basically followed all these directions, including the ones at the Vanderbilt page, but for one reason or another it doesn't always seem to work. Anyway, hope this might be helpful for people who have the same versions of stuff I used.

I was having this same problem on Windows 7 with R 2.12.1 x64 and resolved it by:
Changing the R directory in my PATH variable to C:\Program Files\R\R-2.12.1\bin\x64 (rather than just ...\R-2.12.1\bin).
Copying ...\MySQL Server 5.5\lib\libmysql.dll to ...\MySQL Server 5.5\bin\.
Running R CMD INSTALL RMySQL_0.7-5.tar.gz in cmd.exe (install.packages('RMySQL',type='source') in R still would not work).

I came across this step-by-step guide to install RMySQL under Windows7 64bit.
http://www.ahschulz.de/2013/07/23/installing-rmysql-under-windows/
The software I used are:
Windows 8 OS
R3.0.2 - 64bit
Rtools 3.1
MySQL Server Community Edition 5.6 - 64bit
Following the above guide (with screenshots provided), my installation and loading of the RMySQL package works.
Many thanks to Arne Hendrik Schulz!

As Marek said. There is no windows binary for this package. I had similar troubles on my Mac when I tried to install RPostgreSQL (because there's no binary for Mac) in the end I had to compile it on my own and modify several files.
For the MySQL part(if you don't know much about MySQL), you might want to use WAMP which is admittedly more than you need, but easy to install and to start and shut down.
For some compiling help you might be interested in Rtools
HTH
BTW: What kind of windows do you run (sry, if I missed it)

You however there is one additional requirement at present (with the MySQL server version 5.5 & R2.12.1) follow thehttp://biostat.mc.vanderbilt.edu/wiki/Main/RMySQL instructions at present as the locations of the libmySQL.dll differs to what is expected in the package.
i.e. for the 64bit compiling.
it expects the libmySQL.dll to be in "${MYSQL_HOME}"/bin/libmySQL.dll
so simply copy the dll over to the /bin dir and it will now compile.
for the 32bit compilling.
the libmySQL.lib is expected in "${MYSQL_HOME}"/lib/opt/libmysql.lib
again moving this should solve the problem.
Alternatively, if you don't want to or can't move these files. Then you can edit the source code files:
Makevars.win
Makevars.win32
Makevars.win64
appropriately pointing to /lib/libmysql.dll /lib/libmysql.lib

Add MySQL and RTools directory to the PATH!
Here is my PATH ; ~blah~;C:\Program Files\MySQL\MySQL Server 5.5\bin;c:\rtools\bin;C:\Rtools\gcc-4.6.3\bin;

I was working for last 2 days on Installation of R with RMySQL package, finally got the solution for that, here are the steps to install RMySQL package:-
DOWNLOAD SOFTWARE FROM THE FOLLOWING LINKS:
*a. R2.13.2: Download R from http://cran.stat.sfu.ca/index.html
b. RTools 214: Download RTools from http://cran.cict.fr
c. RMySQL 0.8-0.tar.gz: Download RMySQL from
http://biostat.mc.vanderbilt.edu/wiki/main/RMySQL/RMySQL_0.8-0.tar.gz
d. MySQL Server 5.0: download it from http://dev.mysql.com
e. RSTUDIO (optional): download it from http://rstudio.org*
SET THE FOLLOWING ENVIRONMENT VARIABLES
* a. MYSQL_HOME : <drive>/path to MySQL installation folder
e.g. MYSQL_HOME= C:\Program Files\MySQL\MySQL Server 5.5\
b. R_HOME: <drive>/path to R installation
e.g. R_HOME=C:\Program Files\R\R-2.13.2\
c. PATH: Modify path to accommodate the above variables. *
Be sure that the following paths areincluded in your Windows PATH variable:
\Rtools\2.14\bin
\Rtools\2.14\MinGW\bin
\Rtools\2.14\MinGW64\bin
CREATE FOLDER AND COPY FILES
a. OPT: Create a folder OPT under C:\Program Files\MySQL\MySQL Server 5.5\lib and copy
MYSQLLIB.LIB the above path. Also copy libmysql.dll to \\R\R-2.14.0\bin\ (64 bit) Or \\R\R-2.14.0\bin\i386\ (32 bit) and to C:\Windows\System32.
b. Renviron.site: create or edit a file \\R\R-2.14.0\etc\Renviron.site and add a
line: MYSQL_HOME =”C:/Program Files/MySQL/MySQL Server 5.5/”
NB: USE FORWARD SLASH AND DOUBLE QUOTES HERE
c. libMySQL.dll: Copy this file to C:\Program Files\R\R-2.13.2\bin\i386 as well as C:\Program
Files\R\R-2.13.2\bin
RUN COMMANDS
a. Install.Packages: Run R GUI by clicking on the R icon on desktop or from Start menu. Type
INSTALL.PACKAGES(“RMySQL”,type=”Sources”). This will download the required software from repositories.
b. Command Prompt: Copy the downloaded zip file (in step 4.a.) and paste it under R
installation folder. Go to start menu and open Command Prompt. Go to the R installation folder and type R CMD INSTALL RMySQL_0.8-0.tar.gz
*COMMANDS:
>library(RMySQL)
>drv = dbDriver("MySQL")
>con = dbConnect(drv,host="localhost",dbname="test",user="root",pass="root")
>album = dbGetQuery(con,statement="select * from t_master")
>album*

18 months later, new laptop, same problem. Returning to the scene of the crime - sorry January 2011 self; we're in the future, and this installation still isn't any fun.
Lessons learned:
-Updated RTools are essential. Get them.
-Are you seeing an error along the lines of .onLoad failed in loadNamespace() for 'RMySQL', details? This seems to mean that there's a problem with your system environment variables.
In R, run
Sys.getenv('MYSQL_HOME')
If it spits back a path like
[1] "C:\\Program Files\\MySQL\\MySQL Server 5.6"
you're good. But if it gives you empty string, you need to set this.
These are all Windows 7 directions, but the process is pretty similar in XP, if memory serves.
1) Bring up System Properties > Advanced > Environment Variables.
2) In the lower 'System Variables' pane, click 'New'.
3) Variable name is MYSQL_HOME and value is whatever the path is to your MySQL installation - mine was C:\Program Files\MySQL\MySQL Server 5.6
Newer versions of MySQL don't seem to create an environment variable on install - that and the lack of binaries for RMySQL explain why this questions has garnered 8,000 hits.
-Still stuck? Here are two additional in-depth writeups: 1, 2

Following worked for me in red hat linux
wget http://cran.r-project.org/src/contrib/RMySQL_0.9-3.tar.gz
sudo R CMD INSTALL --configure-args='--with-mysql-inc=/usr/include/mysql' --configure-args='--with-mysql-lib=/usr/lib64/mysql' RMySQL_0.9-3.tar.gz

Related

Problem upgrading from mysql 5.7 to 8.0 in a rails app - missing mysql.so files

I upgraded a working Rails app from Mysql 5.7 to 8.0 on my dev machine but it fails to work on a staging/test server setup with the exact same directory structure and env vars.
I'm getting an error "file not found" for /apps/bundle/ruby/2.7.0/gems/mysql2-0.5.4/lib/mysql2/mysql2.so
ldd /apps/bundle/ruby/2.7.0/gems/mysql2-0.5.4/lib/mysql2/mysql2.so shows a file not found (mysql.so.20) (? - I'm not at work so the filenames might be off) that definitely existed and was part of Mysql 5.7.
So the overall question is how to force the mysql2 gem install to relink to the correct new .so files?
There are a lot of moving parts to this, making things a mystery:
installing mysql from a source tarball,
installing in non-standard directories (apps/usr/local/stow/mysql-8.0.16),
using GNU stow to link mysql .so files from the install directory apps/usr/local/stow/mysql-8.0.16 into a common /apps/usr/local/lib directory (the env var LD_LIBRARY_PATH=/apps/usr/local/lib),
vendoring the gems in the bundle on my dev machine using the bundle package --all command so they're part of the git repo.
I've blown away the /apps/bundle directory contents and rerun bundle install thinking that would force a proper linkage of the .so files without success.
Any ideas? TIA!

FPC IDE: Can't find unit system

I just installed FPC 3.2.0 (on Linux Mint 19.3) and trying to use FPC IDE. I launched the IDE from the bin installation subfolder as ./fp, written a simplest program in IDE
program hello;
begin
writeln('hello');
end.
saved the program as hello.pas and when I compile it I get
(3,1) Fatal: Can't find unit system used by hello
(0) Fatal: Compilation aborted
This is strange because system is the compiler's unit, not a user's unit.
I tried to google the issue, found several posts in different forums, one question was dated back to 2007 year, and none of the questions was answered.
Is where a way to solve the issue or FPC IDE is dead for about 15 years?
Check the unit directories in options->directories -> unit directories.
The package configuration should have put a line like
/usr/lib/fpc/$FPCVERSION/units/$FPCTARGET/*
The dollar values are builtins (respectively 3.2.0 and i386-linux or x86_64-linux). Please verify that the directories with prebuilt .ppu .o are there.
Try to fix your installation of FPC or you can fix it manually by calling fpcmkcfg
fpcmkcfg -d "basepath=path/to/fpc/3.3" -o path/to/fpc.cfg
For instance, if the compiler is in /usr/local/bin, it will look in
/usr/local/etc.
Had the same problem on Ubuntu 20.04. To solve it, I had to create the file fp.cfg in my project's folder with the following content:
-Fu/usr/lib/x86_64-linux-gnu/fpc/$fpcversion/units/$fpctarget
-Fu/usr/lib/x86_64-linux-gnu/fpc/$fpcversion/units/$fpctarget/*
If this will not work, it means unit path on your system is different. You may use something like
dpkg -L fp-units-base-3.0.4 | grep .ppu
to find out where units are actually stored. Replace 3.0.4 with your actual Free Pascal version. If you do not know exact version, use
sudo apt install apt-show-versions
apt-show-versions fpc
It will show something like
fpc:all/focal 3.0.4+dfsg-23 uptodate
3.0.4 is the version number you need.
Another way of getting needed paths is running this command:
cat /etc/fpc.cfg | grep -- -Fu | head -2
So you may just run
cat /etc/fpc.cfg | grep -- -Fu | head -2 > fp.cfg
in your project's folder to have the problem solved.
How to use Free Pascal (Lazarus) on Linux - no install solution:
If not already installed, install "GNU binutils" (sudo apt-get install binutils)
Dowload the latest version of Free Pascal (Lazarus): from the Downloads section of the Lazarus Home page (Lazarus is a professional open-source cross platform IDE powered by Free Pascal):
2.1. In case of a Debian based Linux system (such as Ubuntu): the .deb package could be downloaded ("fpc-laz_<version> ... .deb" (replace <version> with an actual version number))
2.2. In case of a RPM based Linux system (such as Fedora): the .rpm package could be downloaded ("fpc-<version> ... .rpm" (replace <version> with an actual version number))
Extract the downloaded package:
3.1. Place the downloaded .deb / .rpm package in the folder where you are going to extract it
3.2. Extract the downloaded .deb / .rpm package by Right-Click-ing it and then choosing Extract Here
3.3. Rename the extracted folder, as you desire, for example "fpc"; Further we denote this folder as "<BASEFOLDER>" and its path as - "<BASEFOLDER_PATH>"
In the case of a .deb package: Open the extracted <BASEFOLDER> and then, extract "data.tar.xz" - by Right-Click-ing it and then choosing Extract Here
Launch the Free Pascal window by typing the next command in the terminal - this command may vary according to the terminal used - replace <terminal> with the terminal used (by default: for Gnome based Desktop Environments -> gnome-terminal; for KDE based Desktop Environments -> konsole; for Xfce based Desktop Environments -> xfce4-terminal; for the MATE Desktop Environment -> mate-terminal; ...):
<terminal> -e '<BASEFOLDER_PATH>/usr/bin/fp'
OR:
<terminal> -- '<BASEFOLDER_PATH>/usr/bin/fp'
To add the units folders: From the Free Pascal Menu, access: Options -> Directories -> and copy (CTRL + C to Copy from outside the IDE, and (FN + )SHIFT + Insert to Paste inside the IDE) to the "Units" tab, the next three lines, each on a new line (replace <BASEFOLDER_PATH> with its corresponding value, and replace <LIB_FOLDER> with: lib in case of a .deb package or lib64 in case of a .rpm package):
<BASEFOLDER_PATH>/usr/<LIB_FOLDER>/fpc/$fpcversion\units\$fpctarget
<BASEFOLDER_PATH>/usr/<LIB_FOLDER>/fpc/$fpcversion\units\$fpctarget\*
<BASEFOLDER_PATH>/usr/<LIB_FOLDER>/fpc/$fpcversion\units\$fpctarget\rtl
Please note that by moving the files from the <BASEFOLDER> directory to other <BASEFOLDER_PATH>, you'll have to update the above three lines so that they contain the new <BASEFOLDER_PATH>, otherwise you might get errors like:
"Fatal: Can't find unit ..."
For navigation inside the IDE using keyboard - the following shortcuts can be used: Alt + Highlighted-letter, Highlighted-letter(s), Tab / Shift + Tab, Arrows, Enter, Esc
For Official Online Documentation see:
Online Documentation

Using MySQL in R for Windows

How to use MySQL in R (statistic language) for Windows (7)?
There is no problems then using linux:
install.packages('RMySQL')
library(RMySQL)
...
But I found no such package for Windows on CRAN. There is only note about this fact.
I found package for version 2.10, but it is not usable in 2.12.1.
Also tried
install.packages("RMySQL", type="source")
but got an error :
* installing *source* package 'RMySQL' ...
ERROR: configuration failed for package 'RMySQL'
* removing 'C:/.../R/win-library/2.12/RMySQL'
Is there any way to connect to MySQL database from R in windows?
Found solution with help of ran2, who gave me link to common question. The basic process is described here, but there are several hints, So I will describe the whole solution (please change the R version and paths if needed):
Install latest RTools from here
install MySQL or header and library files of mysql
create or edit file C:\Program Files\R\R-2.12.1\etc\Renviron.site and add line like MYSQL_HOME=C:/mysql (path to your mysql files)
copy libmysql.lib from mysql/lib to mysql/lib/opt to meet dependencies.
copy libmysql.dll to C:\Program Files\R\R-2.12.1\bin or to windows/system32 directory.
run install.packages('RMySQL',type='source') and wait while compilation will end.
Thanks to all who tried to answer.
possible duplicate. However, my suggestions is to try WAMP which comes as a one click install. Admittedly you get more than you need (webserver) but the MySQL installation runs pretty well.
You need to install the MySQL headers and libraries, as explained in the installation instructions. Please do read the documentation before turning to SO.

mysql 5.5.9 -- install in windows

I just downloaded zipped-up version of mysql 5.5.9 (mysql-5.5.9.zip, which I put in c:\progream files), unzipped it, and got this dir (screenshot):
http://mayacove.com/misc/ss_mysql.gif
I hadn't installed mysql server on windows in a few years.. I remember that years ago you used to get an installer called setup.exe, when you ran that it ran instal/config wizard, that would walk you thru installation and setup.. so how do I run that wizard now???
no file with ext .exe inside this dir (no file with ext .msi either) no serious instructions here
http://dev.mysql.com/doc/refman/5.5/en/windows-installation-layout.html
would appreciate some help.. thank you very much...
There is a package available with a MSI installer.
Just follow the instructions on http://dev.mysql.com/downloads/mysql/
You should use msi installer. It's on download page first or second option.

"193: %1 is not a valid Win32 application" bug with a new Rails Application

I have a new rails application which I have created under Windows 7 by going into a directory and typing "rails newapp". The creation went fine, and when I access the root page, all is well. However, when I try to access a page that would access the database, I get this:
193: %1 is not a valid Win32 application.
In the developer.log. Mysql is running fine on my machine, and I have other applications which I have running in here in other directories, it's just this one that doesn't work. Any thoughts?
Here's the answer that worked for me. Turns out it was an issue of x64 vs. x32 issue and Rails 2.3.2.
The answer I got from here (http://osdir.com/ml/RubyonRailsTalk/2009-06/msg01775.html):
In case anyone else has the same
problem after a lot of struggling on
my Windows XP x64 machine, with MySQL
5.1.30 (x64) and Rails 2.3.2 installed, this above suggestiong
helped me.
Download libMySql.dll from here (http://instantrails.rubyforge.org/svn/trunk/InstantRails-win/InstantRails/mysql/bin/)
and putting it in ruby\bin solved the
problem.
Solved by following the directions on this blog here: http://blog.mmediasys.com/2011/07/07/installing-mysql-on-windows-7-x64-and-using-ruby-with-it/
which involves using the non installer version of the MySQL Connector http://dev.mysql.com/downloads/connector/c/
I could not get webrick to run on x64 Windows 7 system -- got the same error
"193: %1 is not a valid Win32 application”
If I just replaced the file libmysql.dll (as suggested in posts above), I got a different error.
"Incorrect MySQL client library version!"
My Path set like this: C:\Ruby187\bin;C:\Program Files\MySQL\MySQL Server 5.5\bin;C:\Ruby187\lib\ruby\gems\1.8\gems\rails-3.1.1\bin
(didn't need to change the path again)
This error occurs if you have a file with name "Program" in the root of your drive. Say for example you are trying to execute "C:\Program Files\SomeApp\Bin\SomeExe.Exe" it tries to execute "C:\Program" if it exists. In some situations a file with this name get created if you forget to quote "C:\Program Files..." with some commandline commands. This of course also applies for you D: drive, etc.
This error often occurs if you try to start services, but may occur in other situations.
Simply deleting the file C:\Program or D:\Program etc. solves the problem.
Having run into multiple issues setting up MySQL with Rails on Windows x64 my recommendations are:
Install the 32-bit version of MySQL, do not try to use the 64-bit version.
Install into a path with no spaces, do not accept a default like "C:\Program Files\MySQL\MySQL Server 5.5\"
Install the MySQL gem with an invocation similar to:
gem install mysql -- --platform=ruby --with-mysql-dir="D:\Programs\MySQL\MySQL-Server-5.5" --with-libmysqllib="D:\Programs\MySQL\MySQL-Server-5.5\lib\"
Be sure to uninstall/reinstall the gem whenever you install a new version of MySQL.
Make sure D:\Programs\MySQL\MySQL-Server-5.5\lib is included in your path, as well as D:\Programs\MySQL\MySQL-Server-5.5\bin. Make sure other copies of libmysql.dll are not being picked up from elsewhere on your path or your ruby installation directories.
This worked for me with mysql-5.5.15-win32, mysql-2.8.1-x86-mingw32 and Windows 7 x64.
Copy the file libmysql.dll from your MySQL installation directory and paste it into your Ruby installation's bin directory. You may need to download a zip archive from http://dev.mysql.com/downloads/mysql/ if your MySQL installation directory doesn't already include the file libmysql.dll.
Using Ruby (1.8.7) with MySQL(5.5) on Windows 7 and also getting error 193.
Copying the libmySQL.dll to ruby /bin worked fine for me.
C:\Work\redmine-2.4.1\config\database.yml content:
# Default setup is given for MySQL with ruby1.9. If you're running Redmine
# with MySQL and ruby1.8, replace the adapter name with `mysql`.
# Examples for PostgreSQL, SQLite3 and SQL Server can be found at the end.
# Line indentation must be 2 spaces (no tabs).
production:
adapter: mysql
database: redmine
host: localhost
username: root
password: "pwd#123"
encoding: utf8