As far as I understand you have installed on the same mac box MariaDB and a virtual machine in with you have installed XAMPP. And you tried to make a connection between something running in the VM and something running outside on localhost.
There is something called nmap also for macOS, https://nmap.org/book/inst-macosx.html and you can use it to scan your box and see what services you have on it. Using nmap you could have seen that your not on the same environment. ( ?! )
Anyway I found here some guy telling a very similar story.
It looks like he was able to connect the VM with the localhost and it took him a minute.
The next guy is telling about how to access your service on the host machine in your case the database by the hostname setting the network to bridge. <
On macOS you have ifconfig like on Linux, on windows it is called ipconfig, that gives you all information about all adapters you have and the different ip addresses
root@tux:~# ifconfig
eno1: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.178.33 netmask 255.255.255.0 broadcast 192.168.178.255
inet6 fe80::42a8:f0ff:fea2:1e58 prefixlen 64 scopeid 0x20<link>
ether 40:a8:f0:a2:1e:58 txqueuelen 1000 (Ethernet)
RX packets 366455797 bytes 41401605218 (38.5 GiB)
RX errors 0 dropped 65936 overruns 0 frame 0
TX packets 745920997 bytes 846447546164 (788.3 GiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
device interrupt 20 memory 0xf7c00000-f7c20000
lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536
inet 127.0.0.1 netmask 255.0.0.0
inet6 ::1 prefixlen 128 scopeid 0x10<host>
loop txqueuelen 1 (Lokale Schleife)
RX packets 6945633 bytes 1073031154 (1023.3 MiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 6945633 bytes 1073031154 (1023.3 MiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
But you are right better ask the work to accept ... something.