Configuring WP-CLI on Windows 10

Actually, I figured out how to do this, and it’s actually really easy to do! Which is awesome because I think it’s a great simple way to work!

First up, you don’t want to change the PATH for PHP in bash. So you’ll want to remove that. Instead, what you are doing is using bash based PHP and MySQL, but connecting to your Windows MySQL (installed by XAMPP).

Step 1:

sudo apt install mysql-client php-cli php-mysql

Step 2:

Create a symlink in bash to your website files, so something like this:
sudo ln -s /mnt/c/websites /var/www

Step 3:

You need to connect to you MySQL db with an IP address, not localhost. So when creating your config do something like this:

wp config create --dbname=wpdbname --dbuser=wpdbuser --dbpass=securepswd --dbhost=127.0.0.1

If you want more info, I also wrote a blog post about this.