How to connect to local MySQL Server 8.0 with DBIish in Perl6

Maybe the example in the dbiish repository is not valid anymore.

The DBIISH_MYSQL_LIB Env seems to be replaced by NativeLibs::Searcher with commit 9bc4191

Looking at NativeLibs::Searcher may help to find the root cause of the problem.


This is more of a work around, but being unable to use use a DB is crippling. So even when trying to use the NativeLibs I couldn't get a connection via DBIish. Instead I have opted to using DB::MySQL which is proving to be quite helpful. With a few lines of code this module has your DB needs covered:

use DB::MySQL;

my $mysql = DB::MySQL.new(:database<databaseName>, :user<userName>, :password<passwordHere>);
my @users = $mysql.query('select * from users').arrays;

for @users { say "user #$_[0]: $_[1] $_[2]"; }

#Results would be:
#user #1: FirstName LastName
#user #2: FirstName LastName
#etc...

This will print out a line for each user formatted as shown above. It's not as familiar as DBIish, but this module gets the job done as needed. There's plenty more you can do with it to, so I highly recommend reading the docs.


According to this github DBIish issue 127

The environmental variable DBIISH_MYSQL_LIB was removed. I don't know if anyone brought it back.

However if you add the library's path, and the file is named mysql.dll, it will work. Not a good result for the scientific method.

So more testing is needed - and perhaps

C:\Program Files\MySQL\MySQL Server 8.0\lib>mklink mysql.dll .\libmysql.dll

Oviously you can create your own lib directory and add that to your path and then add this symlink to that directory.

Hope this helps. I've spent hours..

EDIT: Still spending time - accounting later.

Something very transitory is going on. I reset the machine (perhaps always do this from now on), and still got the missing mysql.dll errors. Tried going into the MySQL lib directory to execute raku from there.. worked. changed directories.. didn't work.

Launched administrator cmd - from home directory, tried the raku command. Worked. Ok - not good, but perhaps consistent. Launched non admin cmd, tried it from the MySQL lib directory, worked. And just for giggles, tried it outside of that directory.. worked.

Now I can't get it not to work. Will explore NativeLibs::Searcher as Valle Lukas suggested!

Tags:

Mysql

Raku

Dbi