lunarmodules / luasql

LuaSQL is a simple interface from Lua to a DBMS.
http://lunarmodules.github.io/luasql
539 stars 191 forks source link

Cannot connect to MySQL on CentOS 7 #44

Open dutchie31 opened 8 years ago

dutchie31 commented 8 years ago

I'm trying to compile LuaSQL on CentOS 7 but whatever I try I can't make the module actually connect to a database:

# LuaSQL: Error connecting to database. MySQL: Can't connect to MySQL server on 'x.x.x.x' (111)

CentOS 7 is installed with:

mariadb-devel-5.5.47-1.el7_2.x86_64
mariadb-5.5.47-1.el7_2.x86_64
mariadb-libs-5.5.47-1.el7_2.x86_64
lua-5.1.4-14.el7.x86_64
lua-devel-5.1.4-14.el7.x86_64

I'm building luasql-2.3.1 using the following config:

DRIVER_LIBS_mysql ?= -L/usr/lib64/mysql -lmysqlclient -lz
DRIVER_INCS_mysql ?= -I/usr/include/mysql
LUA_LIBDIR ?= /usr/lib64
LUA_INC ?= /usr/include

# make mysql
gcc -O2 -std=gnu99 -Wall -Wmissing-prototypes -Wmissing-declarations -pedantic -fPIC  -I/usr/include -DLUASQL_VERSION_NUMBER='"2.3.1"'  -c src/luasql.c -o src/luasql.o
gcc -O2 -std=gnu99 -Wall -Wmissing-prototypes -Wmissing-declarations -pedantic -fPIC  -I/usr/include -DLUASQL_VERSION_NUMBER='"2.3.1"'  src/ls_mysql.c -o src/mysql.so -shared src/luasql.o -I/usr/include/mysql -L/usr/lib64/mysql -lmysqlclient -lz
src/ls_mysql.c: In function ‘cur_nullify’:
src/ls_mysql.c:193:1: warning: no return statement in function returning non-void [-Wreturn-type]
 }
 ^

It seems to be generating a valid mysql.so:

# ldd src/mysql.so 
 linux-vdso.so.1 =>  (0x00007fff909bd000)
 libmysqlclient.so.18 => /usr/lib64/mysql/libmysqlclient.so.18 (0x00007f743479b000)
 libz.so.1 => /lib64/libz.so.1 (0x00007f7434585000)
 libc.so.6 => /lib64/libc.so.6 (0x00007f74341c3000)
 libpthread.so.0 => /lib64/libpthread.so.0 (0x00007f7433fa7000)
 libssl.so.10 => /lib64/libssl.so.10 (0x00007f7433d3a000)
 libcrypto.so.10 => /lib64/libcrypto.so.10 (0x00007f7433951000)
 libdl.so.2 => /lib64/libdl.so.2 (0x00007f743374d000)
 libstdc++.so.6 => /lib64/libstdc++.so.6 (0x00007f7433445000)
 libm.so.6 => /lib64/libm.so.6 (0x00007f7433142000)
 /lib64/ld-linux-x86-64.so.2 (0x00007f7434ea9000)
 libgssapi_krb5.so.2 => /lib64/libgssapi_krb5.so.2 (0x00007f7432ef6000)
 libkrb5.so.3 => /lib64/libkrb5.so.3 (0x00007f7432c11000)
 libcom_err.so.2 => /lib64/libcom_err.so.2 (0x00007f7432a0c000)
 libk5crypto.so.3 => /lib64/libk5crypto.so.3 (0x00007f74327da000)
 libgcc_s.so.1 => /lib64/libgcc_s.so.1 (0x00007f74325c4000)
 libkrb5support.so.0 => /lib64/libkrb5support.so.0 (0x00007f74323b4000)
 libkeyutils.so.1 => /lib64/libkeyutils.so.1 (0x00007f74321b0000)
 libresolv.so.2 => /lib64/libresolv.so.2 (0x00007f7431f96000)
 libselinux.so.1 => /lib64/libselinux.so.1 (0x00007f7431d70000)
 libpcre.so.1 => /lib64/libpcre.so.1 (0x00007f7431b0f000)
 liblzma.so.5 => /lib64/liblzma.so.5 (0x00007f74318ea000)

But whenever I use this module it simply fails to connect to MariaDB with the above listed error message. A test connection from the command line works without issues:

# mysql -u[..] -p[..] -h[..]
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 14
Server version: 5.5.47-MariaDB-log MariaDB Server

Copyright (c) 2000, 2015, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [(none)]> 

SELinux is disabled:

# sestatus 
SELinux status:                 disabled

Anyone got LuaSQL successfully built on CentOS 7 or have any idea what's going wrong here?

ycaner06 commented 6 years ago

Hello, i have the similar problem. it is installed on Centos 7 but installion not copy files to shared directory. So it gives error. I tried to so many way but could't find a solution.

`lua: test1.lua:1: module 'luasql.mysql' not found: no field package.preload['luasql.mysql'] no file './luasql/mysql.lua' no file '/usr/share/lua/5.1/luasql/mysql.lua' no file '/usr/share/lua/5.1/luasql/mysql/init.lua' no file '/usr/lib64/lua/5.1/luasql/mysql.lua' no file '/usr/lib64/lua/5.1/luasql/mysql/init.lua' no file './luasql/mysql.so' no file '/usr/lib64/lua/5.1/luasql/mysql.so' no file '/usr/lib64/lua/5.1/loadall.so' no file './luasql.so' no file '/usr/lib64/lua/5.1/luasql.so' no file '/usr/lib64/lua/5.1/loadall.so' stack traceback: C: in function 'require' test1.lua:1: in main chunk

`

[root@localhost luasql]# make mysql gcc -O2 -std=gnu99 -Wall -Wmissing-prototypes -Wmissing-declarations -pedantic -fPIC -I/usr/include/lua5.1 -DLUASQL_VERSION_NUMBER='"2.3.5"' -c src/luasql.c -o src/luasql.o gcc -O2 -std=gnu99 -Wall -Wmissing-prototypes -Wmissing-declarations -pedantic -fPIC -I/usr/include/lua5.1 -DLUASQL_VERSION_NUMBER='"2.3.5"' src/ls_mysql.c -o src/mysql.so -shared src/luasql.o -I/usr/include/mysql -L/usr/lib64/mysql -lmysqlclient -lz [root@localhost luasql]# make install mkdir -p /usr/lib/lua/5.1/luasql cp src/*.so /usr/lib/lua/5.1/luasql

tomasguisasola commented 6 years ago

Hi

The problem is you are installing in a place (/usr/lib/lua/5/1) but searching in another one (as listed by require). You can change your package.cpath or adapt the Makefile to install the driver at the proper place for your OS.

Regards, Tomás

On 2017-09-12 10:08, Yasin CANER wrote:

Hello, i have the similar problem. it is installed on Centos 7 but installion not copy files to shared directory. So it gives error. I tried to so many way but could't find a solution.

lua: test1.lua:1: module 'luasql.mysql' not found: no field package.preload['luasql.mysql'] no file './luasql/mysql.lua' no file '/usr/share/lua/5.1/luasql/mysql.lua' no file '/usr/share/lua/5.1/luasql/mysql/init.lua' no file '/usr/lib64/lua/5.1/luasql/mysql.lua' no file '/usr/lib64/lua/5.1/luasql/mysql/init.lua' no file './luasql/mysql.so' no file '/usr/lib64/lua/5.1/luasql/mysql.so' no file '/usr/lib64/lua/5.1/loadall.so' no file './luasql.so' no file '/usr/lib64/lua/5.1/luasql.so' no file '/usr/lib64/lua/5.1/loadall.so' stack traceback: C: in function 'require' test1.lua:1: in main chunk

[root@localhost luasql]# make mysql gcc -O2 -std=gnu99 -Wall -Wmissing-prototypes -Wmissing-declarations -pedantic -fPIC -I/usr/include/lua5.1 -DLUASQL_VERSION_NUMBER='"2.3.5"' -c src/luasql.c -o src/luasql.o gcc -O2 -std=gnu99 -Wall -Wmissing-prototypes -Wmissing-declarations -pedantic -fPIC -I/usr/include/lua5.1 -DLUASQL_VERSION_NUMBER='"2.3.5"' src/ls_mysql.c -o src/mysql.so -shared src/luasql.o -I/usr/include/mysql -L/usr/lib64/mysql -lmysqlclient -lz [root@localhost luasql]# make install mkdir -p /usr/lib/lua/5.1/luasql cp src/*.so /usr/lib/lua/5.1/luasql

-- You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub [1], or mute the thread [2].

*

Links:

[1] https://github.com/keplerproject/luasql/issues/44#issuecomment-328847846 [2] https://github.com/notifications/unsubscribe-auth/AAIA7Qgf6WTZyDqmjIGcim0cnPL-h32oks5shoJegaJpZM4IQrMS

ycaner06 commented 6 years ago

@tomasguisasola Hi , After copy .so files in src to /usr/share/lua path, it works fine. Thanks