Qt5 MYSQL driver not loaded error - mysql

I have a Fedora 27 64bit OS, and am trying to run a Qt based app which is trying to access a MySQL server (which I can successfully reach from the command line). But my app shows these errors:
QSqlDatabase: QMYSQL driver not loaded
QSqlDatabase: available drivers: QSQLITE QMYSQL QMYSQL3 QODBC QODBC3 QPSQL QPSQL7
ERROR: DATABASE: Open failed with error code [-1]. Driver error [Driver not loaded]. Database error [Driver not loaded]
I've tried everything I could find online but can't solve this. When I check the libqsqlmysql.so dependencies I see:
[root#host lib64]# ldd /home/administrator/Qt/5.7/gcc_64/plugins/sqldrivers/libqsqlmysql.so
/home/administrator/Qt/5.7/gcc_64/plugins/sqldrivers/libqsqlmysql.so: /lib64/libmysqlclient_r.so.16: version `libmysqlclient_16' not found (required by /home/administrator/Qt/5.7/gcc_64/plugins/sqldrivers/libqsqlmysql.so)
linux-vdso.so.1 (0x00007fffde4ef000)
libmysqlclient_r.so.16 => /lib64/libmysqlclient_r.so.16 (0x00007f3188fd8000)
libz.so.1 => /lib64/libz.so.1 (0x00007f3188dc1000)
libcrypt.so.1 => /lib64/libcrypt.so.1 (0x00007f3188b8b000)
libnsl.so.1 => /lib64/libnsl.so.1 (0x00007f3188971000)
libssl.so.10 => /lib64/libssl.so.10 (0x00007f3188705000)
libcrypto.so.10 => /lib64/libcrypto.so.10 (0x00007f31882a7000)
libQt5Sql.so.5 => /home/administrator/Qt/5.7/gcc_64/plugins/sqldrivers/../../lib/libQt5Sql.so.5 (0x00007f3188062000)
libQt5Core.so.5 => /home/administrator/Qt/5.7/gcc_64/plugins/sqldrivers/../../lib/libQt5Core.so.5 (0x00007f3187944000)
libpthread.so.0 => /lib64/libpthread.so.0 (0x00007f3187725000)
libstdc++.so.6 => /lib64/libstdc++.so.6 (0x00007f318739f000)
libm.so.6 => /lib64/libm.so.6 (0x00007f318704a000)
libgcc_s.so.1 => /lib64/libgcc_s.so.1 (0x00007f3186e33000)
libc.so.6 => /lib64/libc.so.6 (0x00007f3186a50000)
libdl.so.2 => /lib64/libdl.so.2 (0x00007f318684c000)
libssl.so.1.1 => /lib64/libssl.so.1.1 (0x00007f31865e0000)
libcrypto.so.1.1 => /lib64/libcrypto.so.1.1 (0x00007f3186158000)
libfreebl3.so => /lib64/libfreebl3.so (0x00007f3185f55000)
libicui18n.so.56 => /home/administrator/Qt/5.7/gcc_64/plugins/sqldrivers/../../lib/libicui18n.so.56 (0x00007f3185abb000)
libicuuc.so.56 => /home/administrator/Qt/5.7/gcc_64/plugins/sqldrivers/../../lib/libicuuc.so.56 (0x00007f3185703000)
libicudata.so.56 => /home/administrator/Qt/5.7/gcc_64/plugins/sqldrivers/../../lib/libicudata.so.56 (0x00007f3183d20000)
libgthread-2.0.so.0 => /lib64/libgthread-2.0.so.0 (0x00007f3183b1e000)
librt.so.1 => /lib64/librt.so.1 (0x00007f3183916000)
libglib-2.0.so.0 => /lib64/libglib-2.0.so.0 (0x00007f3183602000)
/lib64/ld-linux-x86-64.so.2 (0x00007f3189440000)
libpcre.so.1 => /lib64/libpcre.so.1 (0x00007f318338f000)
and sure enough there is no /lib64/libmysqlclient_r.so.16 on my system. And DNF says that nothing provides this file! So I tried to symlink /lib64/libmysqlclient_r.so to /lib64/libmysqlclient_r.so.16 but still no joy.
Can someone offer a solution?

After lots of searching on different sites, the consensus was to recompile the Qt sql drivers from source (which is installed with Qt Creator). Switch to the source directory for SQL drivers then 'make', and 'make install'
After that the error was gone.
Ignore all the suggestions about copying/symlinking different .so files. It doesn't work (anymore).

Related

Use of undefined constant SIGKILL - assumed 'SIGKILL' in Laravel 5.7 queue

I'm getting this error "Use of undefined constant SIGKILL - assumed 'SIGKILL'" from my AJAX request, that starts this artisan command ->
Artisan::call('queue:work', [
'connection' => 'database',
'--memory' => '700',
'--tries' => '1',
'--timeout' => '35000',
'--queue' => 'updates'
]);
I'm using Laravel 5.7 as framework for application.
Jobs are managed from database, configuration ->
'database' => [
'driver' => 'database',
'table' => 'jobs',
'queue' => 'default',
'retry_after' => 18000,
],
Problem appeared recently.. That is weird, because troubles wasn't here before and all this "system" worked just fine. Now worker get some jobs done just fine, but then it drops to error, and writes to table "failed_jobs" in DB this ->
ErrorException: PDOStatement::execute(): MySQL server has gone away in /srv/migration-xxxxxx-xxxx-xxxxxx/www/vendor/laravel/framework/src/Illuminate/Database/Connection.php:458
As DB I'm using Microsoft Azure MySQL DB. Microsoft specialist after consultation find nothing .. server is working correctly. Queries are just fine, not that big to fail.
Please help, don't know what to do, or what is wrong...

Can't import mysql data into elastic search

I'm trying to follow along with a course example haven't recieved any help in the FAQ's, tried everything I could find on google and here.
I'm not using docker just running this demo on my local machine(Ubunutu 18.04), both elastic search and mysql are running.
When I run "sudo bin/logstash -f /etc/logstash/conf.d/mysql.conf --path.settings /etc/logstash"
I get the following Error: com.mysql.jdbc.Driver not loaded. Are you sure you've included the correct jdbc driver in :jdbc_driver_library?
The driver does exist and path is correct.
when I use sudo bin/logstash --config.test_and_exit -f /etc/logstash/conf.d/mysql.conf
It returns with configuration ok.
I'm using mysql-connector-java-5.1.47
openjdk version "1.8.0_181"
OpenJDK Runtime Environment (build 1.8.0_181-8u181-b13-0ubuntu0.18.04.1-b13)
OpenJDK 64-Bit Server VM (build 25.181-b13, mixed mode)
Elasticsearch-6.4.2
Logstash-6.4.2
My mysql.conf is
input {
jdbc {
jdbc_connection_string => "jdbc:mysql://localhost:3306/movielens"
jdbc_user => "grunt"
jdbc_password => "password"
jdbc_driver_library => "/home/alarik/mysql-connecter-java-5.1.47/mysql-connector-java-5.1.47-bin.jar"
jdbc_driver_class => "com.mysql.jdbc.Driver"
statement => "SELECT * FROM movies"
}
}
output {
stdout { codec => json_lines }
elasticsearch {
"hosts" => "localhost:9200"
"index" => "movielens-sql"
"document_type" => "data"
}
}
I solved the problem:
First check your java version:
root#xxxxxx:/# java -version
openjdk version "1.8.0_181"
If you are using 1.8 then you should use the JDBC42 version.
If you are using 1.7 then you should use the JDBC41 version.
If you are using 1.6 then you should use the JDBC43 version.
mysql setup:
mysql-connector-java-5.1.46.jar
jdbc_driver_library => "//path_to_jar/mysql-connector-java-5.1.46.jar"
jdbc_driver_class => "com.mysql.jdbc.Driver"

QMysql Driver not loaded error

When executing the following code I get an error that the Mysql driver is not loaded:
db = QSqlDatabase::addDatabase("QMYSQL");
db.setHostName("127.0.0.1");
db.setDatabaseName("test");
db.setUserName("test");
db.setPassword("test");
if (!db.open()) {
QMessageBox::critical(0, QObject::tr("Database Error"), db.lastError().text());
} else
qDebug() << "OPEN";
and in my .pro file I added it with
QT += core gui sql
I'm using Ubuntu 15.10 and I have installed
libqt5sql5-mysql
libqt4-sql-mysql
and when locating them with I get
locate libqsql
/usr/lib/i386-linux-gnu/qt4/plugins/sqldrivers/libqsqlmysql.so
/usr/lib/x86_64-linux-gnu/qt4/plugins/sqldrivers/libqsqlite.so
/usr/lib/x86_64-linux-gnu/qt5/plugins/sqldrivers/libqsqlite.so
also when running the ldd command all dependencies can be found:
ldd libqsqlite.so
linux-vdso.so.1 => (0x00007fff631e6000)
libsqlite3.so.0 => /usr/lib/x86_64-linux-gnu/libsqlite3.so.0 (0x00007f831f6d3000)
libQt5Sql.so.5 => /usr/lib/x86_64-linux-gnu/libQt5Sql.so.5 (0x00007f831f691000)
libQt5Core.so.5 => /usr/lib/x86_64-linux-gnu/libQt5Core.so.5 (0x00007f831f1d4000)
libstdc++.so.6 => /usr/lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007f831ee52000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f831ea88000)
libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007f831e869000)
libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007f831e665000)
libz.so.1 => /lib/x86_64-linux-gnu/libz.so.1 (0x00007f831e44b000)
libicui18n.so.55 => /usr/lib/x86_64-linux-gnu/libicui18n.so.55 (0x00007f831dfe7000)
libicuuc.so.55 => /usr/lib/x86_64-linux-gnu/libicuuc.so.55 (0x00007f831dc53000)
libpcre16.so.3 => /usr/lib/x86_64-linux-gnu/libpcre16.so.3 (0x00007f831d9f0000)
libglib-2.0.so.0 => /lib/x86_64-linux-gnu/libglib-2.0.so.0 (0x00007f831d6e0000)
librt.so.1 => /lib/x86_64-linux-gnu/librt.so.1 (0x00007f831d4d8000)
libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f831d1d0000)
libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007f831cfb8000)
/lib64/ld-linux-x86-64.so.2 (0x0000557933e71000)
libicudata.so.55 => /usr/lib/x86_64-linux-gnu/libicudata.so.55 (0x00007f831b501000)
libpcre.so.3 => /lib/x86_64-linux-gnu/libpcre.so.3 (0x00007f831b293000)
When executing the code I get as output:
QSqlDatabase: QMYSQL driver not loaded
QSqlDatabase: available drivers: QSQLITE QMYSQL QMYSQL3 QPSQL QPSQL7
Do I need to do something else?

Laravel failing to connect to DB after 4.2 upgrade

I just upgraded my Laravel install from 4.1.(something) to 4.2.7 using the steps recommended here: http://laravel.com/docs/upgrade
Now I'm getting this error on every page:
PDOException (2002)
SQLSTATE[HY000] [2002] Can't connect to local MySQL server through socket '' (111)
MySQL is not running locally, but it's not supposed to be. I don't have any configuration for connecting to local MySQL, my development SQL server is remote. Why is it trying to connect to local?
Is there some config change that isn't mentioned in the upgrade guide? Everything was peachy in 4.1.
From my app/config/database.php file:
'default' => 'mysql',
...
'connections' => array(
'mysql' => array(
'driver' => 'mysql',
'host' => 'myrealdb.us-east-1.rds.amazonaws.com',
'database' => 'myrealdbname',
'username' => 'myrealuser',
'password' => 'myrealpass',
'charset' => 'utf8',
'collation' => 'utf8_unicode_ci',
'prefix' => '',
'database_port' => '3306',
'unix_socket' => '',
),
...
);
I tried php artisan clear-compiled and php artisan dump-autoload just in case. No effect.
Edit: I submitted a fix for this that has been merged into the 4.2 branch. You shouldn't have to worry about this error anymore.
I got it! This appears to be a change in the way Laravel uses the database configuration, I hope this answer helps others.
The short version is: if your connection is configured like mine (in the question), delete the unix_socket entry from the array.
Previously, I always copied and edited the default entries in the connections array, leaving in the unix_socket parameter as empty. Apparently now there's a check that assumes if unix_socket is present, it should use a socket DSN string. The empty string in my config passed the check. You can see how this happens in /vendor/laravel/framework/src/Illuminate/Database/Connectors/MySqlConnector.php. The functions getDsn, getSocketDsn, and getHostDsn tell the story.
Pasted because this will eventually change:
protected function getDsn(array $config)
{
return isset($config['unix_socket']) ? $this->getSocketDsn($config) : $this->getHostDsn($config);
}
...
protected function getSocketDsn(array $config)
{
extract($config);
return "mysql:unix_socket={$config['unix_socket']};dbname={$database}";
}
...
protected function getHostDsn(array $config)
{
extract($config);
return isset($config['port'])
? "mysql:host={$host};port={$port};dbname={$database}"
: "mysql:host={$host};dbname={$database}";
}

An issue when unixodbc dynamically linked with ltdl library?

all:
I am testing unixODBC in Solaris 10 environments, and find if libodbc and MyODBC driver are dynamically linked with libltdl.so:
ldd /usr/lib/libodbc.so.2
libltdl.so.7 => /usr/local/lib/libltdl.so.7
libiconv.so.2 => /usr/local/lib/libiconv.so.2
libthread.so.1 => /usr/lib/libthread.so.1
libc.so.1 => /usr/lib/libc.so.1
libgcc_s.so.1 => /usr/lib/libgcc_s.so.1
libm.so.2 => /usr/lib/libm.so.2
/platform/SUNW,Sun-Fire-V240/lib/libc_psr.so.1
ldd /data/nan/mysql-connector-odbc-5.2.4-src/lib/libmyodbc5a.so
libodbc.so.2 => /usr/lib/libodbc.so.2
libthread.so.1 => /usr/lib/libthread.so.1
libm.so.2 => /usr/lib/libm.so.2
libodbcinst.so.2 => /usr/lib/libodbcinst.so.2
libgcc_s.so.1 => /usr/lib/libgcc_s.so.1
libltdl.so.7 => /usr/local/lib/libltdl.so.7
libiconv.so.2 => /usr/local/lib/libiconv.so.2
libc.so.1 => /usr/lib/libc.so.1
/platform/SUNW,Sun-Fire-V240/lib/libc_psr.so.1
sometimes it will connect MySQL server failed when starting up application. The log likes this:
[ODBC][6738][1361325895.588941][SQLConnect.c][1111]Can't open lib '/data/nan/mysql-connector-odbc-5.2.4-src/lib/libmyodbc5a.so' : file not found
[ODBC][6738][1361325895.588979][SQLConnect.c][1111]Can't open lib '/data/nan/mysql-connector-odbc-5.2.4-src/lib/libmyodbc5a.so' : file not found
After a while, the application runs OK.
But if libodbc and MyODBC driver aren't dynamically linked with libltdl.so:
ldd /usr/local/lib/libodbc.so.2
libiconv.so.2 => /usr/local/lib/libiconv.so.2
libthread.so.1 => /usr/lib/libthread.so.1
libc.so.1 => /usr/lib/libc.so.1
libgcc_s.so.1 => /usr/local/lib/libgcc_s.so.1
libm.so.2 => /usr/lib/libm.so.2
/platform/SUNW,UltraAX-i2/lib/libc_psr.so.1
ldd /data1/susie/mysql/tools/test_static_modify/mysql-connector-odbc-5.2.3-src/lib/libmyodbc5a.so
libodbc.so.2 => /usr/local/lib/libodbc.so.2
libthread.so.1 => /usr/lib/libthread.so.1
libm.so.2 => /usr/lib/libm.so.2
libodbcinst.so.2 => /usr/local/lib/libodbcinst.so.2
libgcc_s.so.1 => /usr/local/lib/libgcc_s.so.1
libiconv.so.2 => /usr/local/lib/libiconv.so.2
libc.so.1 => /usr/lib/libc.so.1
/platform/SUNW,UltraAX-i2/lib/libc_psr.so.1
The application runs always OK..
So I think it may be a potential issue in unixODBC. Could anyone help to check it? Thanks very much in advance!
Best Regards
Nan Xiao
All unixODBC does is call dlopen and dlsym from libltdl, I wonder if there is some statics in the lib that is causing the problem. If you don't build unixODBC to use a exernal libltdl it uses its own version (from libtool), so again, it may be a conflict with them both hitting the same lib. You say you are using Solaris. Is the libltdl you are linking with from Sun?
What might be interesting is if you can get it to fail under truss so we could see just what the "file not found" is caused by.
I also wonder just what the MySQL driver uses libltdl for?