Install and configure WP-CLI in Windows 10 Windows Subsystem Linux (WSL)?


  • | 648 points

    Hi,

    I followed your instructions here https://forum.laragon.org/post/4647 and managed to get WP-CLI working in Windows 10 locally with Laragon, however I tend to develop on WSL and it would be nice if I didn't have to leave my VS Code editor to run wp cli commands.

    I have tried to install WP-CLI as per their instructions:

    wget https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar
    chmod +x wp-cli.phar
    mv wp-cli.phar ~/bin/wp

    But when I try to run WP CLI commands I got this error:

    PHP Notice: Undefined index: HTTP_HOST in phar:///home/username/bin/wp/vendor/wp-cli/wp-cli/php/WP_CLI/Runner.php(1198) : eval()'d code on line 26
    PHP Warning: mysqli_real_connect(): (HY000/2002): No such file or directory in /mnt/c/Users/xxx/xxx/wordpress/wp-includes/wp-db.php on line 1612
    Warning: mysqli_real_connect(): (HY000/2002): No such file or directory in /mnt/c/Users/xxx/xxx/wordpress/wp-includes/wp-db.php on line 1612
    Error: No such file or directory

    So I installed mysql on WSL but now I get an access denied error Access denied for user 'root'@'localhost' so I think I just have to somehow to the WSL WP-CLI to use the mysql version in the laragon folder, is that right?

    Any help would be much appreciated, thanks for such a great bit of software!

    Cheers


Log in to reply
 

Looks like your connection to Laragon was lost, please wait while we try to reconnect.