in reply to Re^3: Perl XAMPP DB Connect issue (Windows/Strawberry?) - Perl on Windows/WSL References
in thread Perl XAMPP DB Connect issue (Windows/Strawberry?)

If it were my computer, based on what little I know, I would have zero interest in downgrading to Windows 11. But it's not even mine.

As for using 17 GB, and still without a DBI/DBD solution, that illustrates the issue. I think I'm in about 2 GB total right now: XAMPP takes about 700 MB, plus I've had to install MSYS2: 277 MB; 7-Zip: 6 MB; plus my database itself is around 1 GB. But the main thing is (if I could get it to work--and this is the second round of trying, so far without success), it would be much easier to utilize--just browse to the local file in the browser, no muss, no fuss with starting a VM, etc.

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

Blessings,

~Polyglot~

  • Comment on Re^4: Perl XAMPP DB Connect issue (Windows/Strawberry?)

Replies are listed 'Best First'.
Re^5: Perl XAMPP DB Connect issue (Windows/Strawberry?)
by kcott (Archbishop) on Jan 01, 2023 at 08:57 UTC

    G'day Polyglot,

    Firstly, I'm not a big MSWin user and mostly avoid working with it directly. So, feel free to question anything that follows.

    "... downgrading to Windows 11." [my additional emphasis]

    To the best of my knowledge, "Windows 11" is the latest MSWin offering. Perhaps a typo, or misunderstanding, with "downgrading".

    "Does anyone here have it running natively, sans VM?"

    Yes, I do. From cmd.exe:

    Microsoft Windows [Version 10.0.19045.2364] (c) Microsoft Corporation. All rights reserved. C:\Users\ken>perlmodver DBI Module: DBI Version: 1.642 Location: C:/Users/ken/local/opt/strawberry_perl/5_026_003/install/per +l/vendor/lib/DBI.pm C:\Users\ken>perlmodver DBD::mysql Module: DBD::mysql Version: 4.049 Location: C:/Users/ken/local/opt/strawberry_perl/5_026_003/install/per +l/vendor/lib/DBD/mysql.pm

    perlmodver is a quick-and-dirty script that I set up some years ago. It determines if modules are installed and, if so, their version and location.

    C:\Users\ken>where perlmodver C:\Users\ken\local\bin\perlmodver.bat C:\Users\ken>more C:\Users\ken\local\bin\perlmodver.bat @echo off perl -E "my ($err_msg, $missing); BEGIN { $err_msg = q{}; $missing = 0 +; eval { require %1; 1; } or ($err_msg, $missing) = ($@,1); } say q{M +odule: %1}; if ($missing) { say qq{Not installed.\n\@INC:}; say qq{\t +$_} for @INC; say qq{ERROR MESSAGE:\n$err_msg}; } else { say qq{Versi +on: $%1::VERSION\nLocation: $INC{q{%1} =~ s{::}{\/}gr . q{.pm}}}; }"

    I would have installed StrawberryPerl v5.26.3 about four years ago; my memory of doing this is now somewhat hazy. I'm 99% certain that I would have installed the DBI and DBD::mysql modules via the cpan utility.

    If you're installing via cpan — there are other utilities to do the same, e.g. cpanm & cpanp — ensure that cpan.exe (or equivalent) is in the same bin/ directory as perl.exe.

    C:\Users\ken>where perl C:\Users\ken\local\opt\strawberry_perl\5_026_003\install\perl\bin\perl +.exe C:\Users\ken>where cpan C:\Users\ken\local\opt\strawberry_perl\5_026_003\install\perl\bin\cpan +.bat

    You will need to install the DBI and DBD::mysql modules with the Perl version you're using. You can't simply copy them from another installation and expect them to work. I suspect this may be (at least part of) the problem you describe in "Re^2: Perl XAMPP DB Connect issue (Windows/Strawberry?)"; although, I am somewhat guessing about that.

    — Ken

      Many so-called "upgrades" are actually downgrades--which was why I had italicized the word in my earlier remark. I'm aware that version 11 is newer; I just do not happen to prefer it.

      Regarding the DBD::mysql -- it appears I just needed to do all this a few years ago. It might have worked back then.

      I appreciate your help. Yes, I have been attempting to install from the source tarballs--haven't just copied anything in, unless unzipping the portable-format Strawberry Perl that I downloaded counts--version 5.32.1.1, FWIW.

      Blessings,

      ~Polyglot~

Re^5: Perl XAMPP DB Connect issue (Windows/Strawberry?)
by pryrt (Abbot) on Jan 03, 2023 at 20:29 UTC
    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:

    • use my above sequence to prove to yourself that the fault doesn't lie in strawberry portable (you might need to start with a clean unzip from the portable, to avoid the weird state you are currently in after all your experimentation); use portableshell.bat (which shipped with strawberry) to make sure the environment is right (or set up the PATH yourself, as listed elsewhere in this discussion), so all perl should be run from that environment.
    • Pure Strawberry Perl (no XAMPP first!)
    • use cpanm DBD::MariaDB to install what other monks have recommended as a superior interface to MySQL/MariaDB, though DBD::mysql is functional at my level of usage
    • Use Mojolicious as your framework and starting with Mojolicious::Guides::Tutorial to help you get started
      • it comes with the Morbo server, so you don't need Apache or other webserver software at all.
      • once again, I am not an expert (so cannot really help), but that Tutorial was enough to enable me to get some simple Mojolicious::Lite -based scripts running through my shared webhost's server (that is: you don't need to use their morbo server, though you can if that's what you want; if you already have a working server, Mojolicious/Mojolicious::Lite will work fine through the Common Gateway Interface)
      • Alternately, other monks prefer Dancer2, but I cannot say anything about that

    Does anyone here have it running natively, sans VM

    Q.E.D.