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?

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

  • I have the password correct. I put "passwordhere" in posting this to Stack Exchange because I don't want to put out my passwords. It didn't ask me for a password but I managed to fix that anyway by logging in as root and changing the root password. Also I'm not on a virtual machine. I'm using WSL. If you check my edit you can also see the new wrinkle in the issue and that it confirms the fact that my passwords etc are correct. The problem it raises then is that I can't connect to the jackalope database which is weird because I'm trying to create it. – David A. French Sep 13 at 12:34

Your Answer

 
discard

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.