If you’re having a hard time installing WP-CLI on your OS X + XAMPP machine due to database connection issue, I found this post by Gabe useful: Beginner’s Guide: Installing WP-CLI with AMPPS. The key is at Configure WP-CLI to use AMPPS binaries part.
Make sure you adjust the path tho. In my case, instead of using:
/Applications/AMPPS/php/bin:/Applications/AMPPS/mysql/bin:$PATH I’m using