Tools like XAMP, MAMP or WAMP have their own PHP and MySQL binaries and do not use a potential globally installed version.
I guess you are using MySQL installed with XAMP, so the socket is not the
default one that you could search in your system but the one in XAMP.
You have two options:
- Update your global PHP's php.inito set thepdo_mysql.default_socketormysqli.default_socketto the MySQL socket in your XAMP installation
in order to your global PHP binary will be able to connect the your XAMP's
MySQL version.
- Use the XAMP's PHP binary (recommanded).
The recommanded option is the second one, because the XAMP's PHP binary is
already configured to use the right MySQL socket and does not need to
update any configuration file.
I explain below how to find the MySQL socket and how to locate the PHP binary directory.
Find the MySQL socket path:
- Write the following code in you Web server directory (usually - www/,- htdocs/or- public_html/)
 - <?php
//phpinfo.php
phpinfo();
 
- Open the URL - http://localhost/phpinfo.phpin your Web browser (adapt the
host name if required).
 
- According to the PHP extension you use to connect to the datase search for
either - pdo_mysql.default_socketor- mysqli.default_socketand you'll
find the path to the socket file.
 
See phpinfo().
Find the PHP binary directory:
- Write the following code in your Web server directory - <?php
//bindir.php
echo PHP_BINDIR;
 
- Open the URL - http://localhost/bindir.phpin your Web browser.
 
- The path to the directory hosting the PHP binary is written.
Thanks to this answer for the information.
See the documentation about pre-defined constants.
In your case the directory hosting PHP is /Applications/XAMPP/bin/ so you
should run the command:
/Applications/XAMPP/bin/php artisan migrate