Installing Levenstein Functions on centos 6 cloud server - mysql

I'd like to install the following UDF's from sam J levy's site
I have run through the windows (32 bit) installation with wamp for my testing server with no problem. Now I have my proper server running centOs 6.4. I have copied the .so files to
usr/lib64/mysql/plugin/damlev.so
I then try to run one of the sql statements to create the function
CREATE FUNCTION damlev RETURNS INTEGER SONAME 'damlev.so';
And get the following error
1126 - Can't open shared library 'damlev.so' (errno: 22 /usr/lib64/mysql/plugin/damlev.so: wrong ELF class: ELFCLASS32)
What Am I doing wrong. Is it because the server is 64bit?
Edit Bounty Started:
If more details about the server are required I can gladly supply them. I need this function installed.

It seems that you're trying to use the damlev.so library included in the damlev.zip file of the Levi's site, but that library is for an Ubuntu 32-bit system, therefore it cannot work on your Centos 64-bit system, so you'll have to compile from sources.
As a prerequisite, you must install the g++ compiler and the mysql development libraries:
yum install gcc-c++ mysql-devel
Also, if you don't have wget and unzip, install them with the following command:
yum install wget unzip
Then download the source code and unzip it somewhere:
cd tmp
mkdir damlev
cd damlev
wget http://samjlevy.com/wp-content/uploads/2011/03/damlev.zip
unzip damlev.zip
cd src
Finally compile, install the plugin and restart the mysql server:
g++ -fPIC -I /usr/include/mysql/ -o damlev.so -shared damlev.cpp
cp damlev.so /usr/lib64/mysql/plugin/
service mysql restart
Please note that all the above command must be run as "root".

Related

Error installing RMySQL to run in Docker on Mac OS X

I am trying to run MySQL in an R script running inside a Docker (actually Rocker) container, but am getting an error on the “install_packages(…” step. The only solution I found that was somewhat similar was specific to running RedHat Linux (I am running Mac OS X 10.15) and the solution included pointing to several directories that I do not have. Running under RStudio or from the command line, RMySQL loads without a problem.
Dockerfile:
FROM rocker/r-ver:latest
RUN mkdir /home/analysis
COPY install_packages.R /home/analysis/install_packages.R
COPY script_basic.R /home/analysis/script_basic.R
RUN Rscript /home/analysis/install_packages.R
CMD Rscript /home/analysis/script_basic.R
R files:
script_basic.R
library( RMySQL )
install_packages.R
install_packages(“RMySQL”)
Commands and responses:
$ docker build -t myapp .
…
Successfully tagged myapp:latest
$ docker run -it --rm myapp
Loading required package: DBI
Error: package or namespace load failed for ‘RMySQL’ in dyn.load(file, DLLpath = DLLpath, ...):
unable to load shared object '/usr/local/lib/R/site-library/RMySQL/libs/RMySQL.so':
libmysqlclient.so.21: cannot open shared object file: No such file or directory
Execution halted
$
I believe that rocker/r-dev does not include the libraries you need to get this to run. Untested, but try something like this.
Dockerfile
FROM rocker/r-ver:latest
RUN mkdir /home/analysis
RUN apt-get update \
&& apt-get install -y --no-install-recommends libmariadbclient-dev
COPY install_packages.R /home/analysis/install_packages.R
COPY script_basic.R /home/analysis/script_basic.R
RUN Rscript /home/analysis/install_packages.R
CMD Rscript /home/analysis/script_basic.R
You can find the need for certain libraries on https://cran.r-project.org/web/packages/RMySQL/index.html, as
SystemRequirements: libmariadb-client-dev | libmariadb-client-lgpl-dev | libmysqlclient-dev (deb), mariadb-devel (rpm), mariadb | mysql-connector-c (brew), mysql56_dev (csw)
and a note on how to install them in RMySQL's github README.md's Installation section.
(The CRAN page references libmysqlclient-dev, but the github page suggests "the mariadb implementation is much better". I don't know the premise of the statement, just explaining why I suggested one and CRAN listed another.)

MySQL atomic library missing error during MyChem installation using cmake

I'm trying to install a tool (MyChem) using cmake on our Ubuntu EC2 instance, the tool I'm installing should utilize mysql so I installed it first. But when I tried to install the tool its says mysql atomic library is missing. What is atomic library? Anybody knows why or how to solve this?
I installed mysql first as follows:
$ sudo apt upgrade
$ sudo apt-get install build-essential
$ sudo apt-get install mysql-server mysql-client
$ sudo apt-get install libmysqlclient-dev
And the followings are the error messages:
$ cmake ..
-- The build type is RelWithDebInfo
-- Test module disabled
-- Could NOT find PkgConfig (missing: PKG_CONFIG_EXECUTABLE)
-- Using mysql-config: /usr/bin/mysql_config
-- MySQL Version: 5.7.29
-- MySQL Plugin Dir: /usr/lib/mysql/plugin
-- Found MySQL 5.7.29: /usr/include/mysql, /usr/lib/x86_64-linux-gnu/libmysqlclient.so;/usr/lib/x86_64-linux-gnu/libpthread.so;/usr/lib/x86_64-linux-gnu/libz.so;/usr/lib/x86_64-linux-gnu/libm.so;/usr/lib/x86_64-linux-gnu/librt.so;MYSQL_LIBRARIES_atomic-NOTFOUND;/usr/lib/x86_64-linux-gnu/libssl.so;/usr/lib/x86_64-linux-gnu/libcrypto.so;/usr/lib/x86_64-linux-gnu/libdl.so
-- Mychem installation directory: /usr/lib/mysql/plugin
-- Defining dlhandler source files
CMake Error: The following variables are used in this project, but they are set to NOTFOUND.
Please set them or make sure they are set and tested correctly in the CMake files:
MYSQL_LIBRARIES_atomic
linked by target "mychem-lib" in directory /home/ubuntu/mychem-1.0.0/src
linked by target "modification_test" in directory /home/ubuntu/mychem-1.0.0/tests
...
-- Configuring incomplete, errors occurred!
From above, around in the middle, you should be able to see the error messages such as MYSQL_LIBRARIES_atomic-NOTFOUND and also
CMake Error: The following variables are used in this project, but they are set to NOTFOUND. Please set them or make sure they are set and tested correctly in the CMake files: MYSQL_LIBRARIES_atomic
at the bottom.

How to link mysql-client installed from Homebrew with diesel-cli?

I have been trying to install the Rust Diesel CLI tool using cargo install diesel_cli, but the installation fails with a linking error
ld: library not found for -lmysqlclient
clang: error: linker command failed with exit code 1
(use -v to see invocation)
I installed the MySQL client using Homebrew: brew install mysql-client. During installation I got the following warning:
mysql-client is keg-only, which means it was not symlinked into /usr/local,
because conflicts with mysql.
If you need to have mysql-client first in your PATH run:
echo 'export PATH="/usr/local/opt/mysql-client/bin:$PATH"' >> ~/.bash_profile
For compilers to find mysql-client you may need to set:
export LDFLAGS="-L/usr/local/opt/mysql-client/lib"
export CPPFLAGS="-I/usr/local/opt/mysql-client/include”
I set the PATH and flags as in that warning message, but I still get the above linking error when trying to install the diesel-cli tool. I am unfamiliar with how to do linking in Rust - are there extra steps I need to do here to link mysqlclient directly?
Cargo ignores LDFLAGS and CPPFLAGS, you should set RUSTFLAGS instead. Something like this untested invocation:
RUSTFLAGS="-L/your_lib -I/your_include" cargo install diesel_cli
Relevant documentation.
On my side, I did not make it work with a mysql-client only. I had to install mysql with
brew install mysql
In the end, what matters is that you have a version of the mysqlclient dynamic lib.
Mines where installed here :
/usr/local/lib/libmysqlclient.21.dylib
/usr/local/Cellar/mysql/8.0.15/lib/libmysqlclient.21.dylib
And it worked.

Use MySQL from AMPPS with Rails

I'm trying to use Rails with the MySQL bin from Ampps, but when I run the command rails generate scaffold User name:string email:string I get the following error:
dyld: lazy symbol binding failed: Symbol not found: _mysql_server_init
Referenced from: /Users/myusername/.rvm/gems/ruby-2.2.1/gems/mysql2-0.4.2/lib/mysql2/mysql2.bundle
Expected in: flat namespace
dyld: Symbol not found: _mysql_server_init
Referenced from: /Users/myusername/.rvm/gems/ruby-2.2.1/gems/mysql2-0.4.2/lib/mysql2/mysql2.bundle
Expected in: flat namespace
I have already configured Ampps Mysql with my environment but I can not managed to make it work with rails, I have the following configurations.
$ which mysql
/Applications/AMPPS/mysql/bin/mysql
$ echo $PATH
/Users/myusername/.rvm/gems/ruby-2.2.1/bin:/Users/myusername/.rvm/gems/ruby-2.2.1#global/bin:/Users/myusername/.rvm/rubies/ruby-2.2.1/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Users/myusername/.rvm/gems/ruby-2.2.1/bin:/Users/myusername/.rvm/gems/ruby-2.2.1#global/bin:/Users/myusername/.rvm/rubies/ruby-2.2.1/bin:/Applications/AMPPS/php-5.4/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Users/myusername/.rvm/bin:/Users/myusername/.rvm/bin:/Applications/AMPPS/mysql/bin
$ ls -l /usr/local/lib/libmy*.dylib
lrwxr-xr-x 1 myusername admin 53 Jan 1 19:30 /usr/local/lib/libmysqlclient.18.dylib -> /Applications/AMPPS/mysql/lib/libmysqlclient.18.dylib
I have tried doing commands but with no success:
$ gem install mysql2 -- --with-mysql-lib=/Applications/AMPPS/mysql/lib --with-mysql-include=/Applications/AMPPS/mysql/include --with-mysql-config=/Applications/AMPPS/mysql/bin/mysql_config
And
bundle config build.mysql2 --with-mysql-lib=/Applications/AMPPS/mysql/lib --with-mysql-include=/Applications/AMPPS/mysql/include --with-mysql-config=/Applications/AMPPS/mysql/bin/mysql_config
bundle install
Any ideas?
I downloaded this AMPPS package and did a quick check on the MySQL binary:
$ file /Volumes/AMPPS/AMPPS/mysql/bin/mysql
/Volumes/AMPPS/AMPPS/mysql/bin/mysql: Mach-O executable i386
Your 64-bit Ruby install is trying to link to 32-bit MySQL libraries, and is not finding what it's looking for. "Symbol not found" errors are often an indication of an architecture mismatch.
My advice to you would be to install these programs from a package management system such as MacPorts or Homebrew. I'm partial to MacPorts, so I'll give you instructions for that. I get the impression Homebrew is more popular, but haven't used it myself.
Install Xcode and the Xcode Command Line Tools
Agree to Xcode license in Terminal: sudo xcodebuild -license
Install MacPorts: https://distfiles.macports.org/MacPorts/MacPorts-2.3.4-10.11-ElCapitan.pkg
Update the port list: sudo port selfupdate
Install away: sudo port install mysql56 rb-rails rb-mysql
Update regularly: sudo port selfupdate && sudo port -uc upgrade outdated
This way you're getting properly built binaries for your system, you can easily keep them up to date, and you aren't filling your system up with 2 gigabytes of things you aren't necessarily going to use (5 different versions of PHP, a couple of database servers, Perl, Python, etc.) In addition, you also get up-to-date versions of other utilities like Ruby, rather than relying on the outdated version that ships with the operating system.

MySQL 5.6 install on debian ERROR:

I'm trying to install MySQL 5.6 on Debian.
Here what I do:
sudo dpkg -i mysql-5.6.12-debian6.0-i686.deb
cd /usr/local
ln -s /opt/mysql/server-5.6 mysql
cd mysql
scripts/mysql_install_db.sh --user=mysql --datadir=/var/lib/mysql
And this is the error that I get:
FATAL ERROR: Could not find #bindir#/my_print_defaults
If you compiled from source, you need to run 'make install' to
copy the software into the correct location ready for operation.
If you are using a binary release, you must either be at the top
level of the extracted archive, or pass the --basedir option
pointing to that location.
Could you please suggest something? I'm installing MySQL from scratch (previous version was completely removed).
Thanks.
I might not be able to help with the error you're getting. But apt-get install -f mysql-server-5.5 worked for me on Debian Wheezy. Try replacing 5.5 with 5.6 and see if it works as well, and probably precede it with sudo.