MySQL connection using SQLDatabaseMBS

I have been able to connect to MySQL databases via SQLDatabaseMBS on macOS for years, but it is failing on my latest application.

I don’t know if it’s because of my upgrading to Mojave, within SQLDatabaseMBS or my host MySQL (v5.7.24), so I loaded Christian’s example below, put in my data and tried it, but it still fails to connect. I can connect using another tool (Sequel Pro), so I know it is possible.

I have tried my usual 64-bit ‘libmysqlclient.20.dylib’, the older 32-bit '‘libmysqlclient.18.dylib’ and the new ‘libmysqlclient.21.dylib’, but none connect. I have also tried installing the latest mysql Server 8.0.13 and connect to it’s included library, but it still will not connect.

Any clues?

[code]Dim db As New SQLDatabaseMBS
Dim f As FolderItem = GetFolderItem("/usr/local/mysql-8.0.13-macos10.14-x86_64/lib/libmysqlclient.21.dylib", FolderItem.PathTypeShell)

// where is the library?
// you can place the database client library files where you want.
// example code just has some convenient location for testing.

'db.SetFileOption SQLConnectionMBS.kOptionLibraryMySQL, SpecialFolder.UserHome.Child(“libmysqlclient.dylib”)
'db.SetFileOption SQLConnectionMBS.kOptionLibraryMySQL, SpecialFolder.Desktop.Child(“libmysqlclient.20.dylib”)
'db.SetFileOption SQLConnectionMBS.kOptionLibraryMySQL, SpecialFolder.Desktop.Child(“libmysqlclient.21.dylib”)
db.SetFileOption SQLConnectionMBS.kOptionLibraryMySQL, f

// connect to database
// in this example it is Oracle,
// but can also be Sybase, Informix, DB2
// SQLServer, InterBase, SQLBase and ODBC

db.DatabaseName=“mysql:mysql.MyAppName.com,3306@myDatabase”
db.UserName=“myUserName”
db.Password=“myPassword”

If db.Connect Then

MsgBox “We are connected!”

dim con as SQLConnectionMBS = db.Connection
MsgBox "Server Version: "+con.ServerVersionString

// Disconnect is optional
// autodisconnect will ocur in destructor if needed

else
MsgBox db.ErrorMessage
end if

db.Close[/code]

MySQL gives the error:

[code]dlopen(libmysqlclient_r.dylib, 1): image not found
dlopen(libmysqlclient_r.15.dylib, 1): image not found
dlopen(libmysqlclient_r.16.dylib, 1): image not found
dlopen(libmysqlclient_r.18.dylib, 1): image not found
dlopen(libmysqlclient.dylib, 1): image not found
dlopen(libmariadb.dylib, 1): image not found

DBMS API Library loading fails
This library is a part of DBMS client installation, not SQLAPI++
Make sure DBMS client is installed and
this required library is available for dynamic loading
[/code]

before passing in a file path, you could check with exists on the folderitem whether the file is there.

You may be looking in the wrong folder.

Yes, I had copied the file to the correct locations and verified that they were correct.

this is strange, especially as the error message above have no paths!?

I found a typo in mysql.cpp here, so it looks like the last SQLAPI update brought that.

I’ll rebuild you a new copy of the plugin.

The link:
https://www.dropbox.com/sh/ifcgf745zm0g5p6/AAD7APgbyStTWx2ZOC9-YKSwa?dl=0

and finally uploaded.

Working again!