Site icon Hip-Hop Website Design and Development

Trying to install WordPress on WSL Windows 10, and running into issues with wp-cli and "wp db create"

Okay so I’m following this tutorial:
https://hellojason.net/blog/how-to-setup-wordpress-locally-on-windows-subsystem-for-linux/

I had to do a bunch of monkey around to get MySQL to work because for some reason when it originally installed it didn’t ask me for a root password so I had to go in and give it one.

I install WP into a folder like it says, and then I start the process of creating the config files but I can’t because I’m getting these errors:

wp config create --dbname=jackalope --dbhost=localhost --dbuser=root --dbpass=passwordhere
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)

And so I try it with sudo:

sudo wp config create --dbname=jackalope --dbhost=localhost --dbuser=root --dbpass=passwordhere
[sudo] password for david:
Do not run Composer as root/super user! See https://getcomposer.org/root for details


  [SymfonyComponentConsoleExceptionRuntimeException]
  The "--dbname" option does not exist.


config [-g|--global] [-e|--editor] [-a|--auth] [--unset] [-l|--list] [-f|--file FILE] [--absolute] [--] [<setting-key>] [<setting-value>]...

I try copying and pasting in the config file from my existing production site instead and then moving on to the next command:

wp db create
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)

So then I try running that with sudo and I get this again:

sudo wp db create
[sudo] password for david:
Do not run Composer as root/super user! See https://getcomposer.org/root for details


  [SymfonyComponentConsoleExceptionCommandNotFoundException]
  Command "db" is not defined.

I’m not really clear on what I’m doing wrong or why this isn’t working. I’m thinking it has something to do with the fact that I installed composer? I’ve never used composer before but the tutorial said to install it and I figure that I probably should learn how to use it since I’ve been learning how to use other package managers like NPM etc.

EDIT:
Okay so I noticed that previous instructions with wp had been “wp core” so I tried and got this:

 wp core db create
Error: Can’t select database. We were able to connect to the database server (which means your username and password is okay) but not able to select the `jackalope` database.

Why? It’s supposed to be creating the database so why does it get confused not being able to find it?

EDIT2:

So I realize that maybe the issue is because root doesn’t have the grants it’s supposed to have? So I look up all users and their grants and I get this:

| 'mysql.session'@'localhost'    | def           | SUPER                   | NO           |
| 'mysql.sys'@'localhost'        | def           | USAGE                   | NO           |

Is this perhaps the cause of the issue?