in reply to Re^4: Perl XAMPP DB Connect issue (Windows/Strawberry?)
in thread Perl XAMPP DB Connect issue (Windows/Strawberry?)

But, alas! It looks like perl/DBI cannot work on Windows outside of a VM. Does anyone here have it running natively, sans VM?

Using my normal portable-based installation of Strawberry Perl, which came pre-installed with DBI and DBD::mysql (I didn't have to install those at all, because strawberry ships with them)

C:> perl -V:myuname myuname='Win32 strawberry-perl 5.32.1.1 #1 Sun Jan 24 15:00:15 2021 x6 +4'; C:> perl -MDBI -MDBD::mysql -le "print join qq(\t), $DBI::VERSION, $DB +D::mysql::VERSION" 1.643 4.050

winver shows Windows 10, 20H2 19042.2364

Download mariadb-10.10.2-winx64.zip from https://dlm.mariadb.com/browse/mariadb_server/214/1565/winx64-packages/

Follow instructions here to take the minimal files for a "portable" MariaDB, including optional bin\mysql_install_db.exe and unmentioned bin\mysql.exe (to give me a client to test with)

> .\bin\mysql_install_db.exe --datadir=data Running bootstrap Creating my.ini file 2023-01-03 11:57:26 0 [Note] C:\usr\local\apps\MariaDB.Portable\bin\my +sqld.exe (server 10.10.2-MariaDB) starting as process 3752 ... Removing default user Creation of the database was successful > start bin\mysqld.exe --console (opens in new window: shows port 3306)

Logon as root and create user pryrt and database test_db, similar to incantations here:

MariaDB [(none)]> CREATE USER pryrt@localhost IDENTIFIED BY 'password' +; Query OK, 0 rows affected (0.015 sec) MariaDB [(none)]> CREATE DATABASE test_db; Query OK, 1 row affected (0.002 sec) MariaDB [(none)]> GRANT ALL PRIVILEGES ON test_db.* TO pryrt@localhost + IDENTIFIED BY 'password'; Query OK, 0 rows affected (0.014 sec) MariaDB [(none)]> FLUSH PRIVILEGES; Query OK, 0 rows affected (0.001 sec) MariaDB [(none)]> quit Bye

Verify from command-line that pryrt user works:

> bin\mysql -u pryrt -ppassword test_db ... logged in okay, and quit...

Prove that the Strawberry pre-installed DBI & DBD::mysql is sufficient to connect to a running MariaDB/MySQL database:

> perl -MDBI -le "print DBI->connect('DBI:mysql:database=test_db', 'pr +yrt', 'password');" DBI::db=HASH(0x36eca40) C:\usr\local\apps\MariaDB.Portable > perl -MDBI -le "print DBI->connect('DBI:mysql:database=test_db', 'pr +yrt', 'passwordx');" DBI connect('database=test_db','pryrt',...) failed: Access denied for +user 'pryrt'@'localhost' (using password: YES) at -e line 1.

(second run was used to prove that it would show an error rather than "DBI::db=HASH(0x....)" if there was a problem)

And this is someone who has only touched MariaDB/MySQL a few times as briefly as possible; in Perl, I am more likely to use DBD::SQLite or DBD::CSV.

But the assertion that "It looks like perl/DBI cannot work on Windows outside of a VM" is easily falsifiable even by someone with my limited database skillset -- even with the hidden MariaDB/MySQL assumption that you baked into that (because with DBD::SQLite or DBD::CSV , you don't need an external application for the database at all, and the sequence to getting it working is even easier)

Whether you want to continue going down the XAMPP road is up to you. But if you're not married to the idea of XAMPP's Apache as the server, and outdated CGI as the interface, (and assuming you don't need the PHP capabilities), and instead just want a simple "portable"(ish) webserver with Perl, then might I recommend:

Does anyone here have it running natively, sans VM

Q.E.D.