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


  [Symfony\Component\Console\Exception\RuntimeException]
  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


  [Symfony\Component\Console\Exception\CommandNotFoundException]
  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?

Topic wp-cli windows installation Wordpress

Category Web


The error has nothing to do with your setup. It says that your connection credential to MySQL database is incorrect.

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

When you were setting up the MySQL by following the tutorial

sudo apt install -y lamp-server^

It probably did ask you to set a password for MySQL. So you should replace passwordhere with the password you have set during the installation process.

wp config create --dbname=jackalope --dbhost=localhost --dbuser=root --dbpass=put-your-password-here-the-one-you-set-during-installation-process

If it doesn't work you can try with your virtual machine password or root

wp config create --dbname=jackalope --dbhost=localhost --dbuser=root --dbpass=root

Note: However, if you are pretty sure the password is correct, try replace localhost with 127.0.0.1

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.