Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Env: Access denied for user 'username_here'@'X.X.X.X' error running wp-env start. #29752

Closed
StevenDufresne opened this issue Mar 11, 2021 · 8 comments
Assignees
Labels
[Status] In Progress Tracking issues with work in progress [Tool] Env /packages/env

Comments

@StevenDufresne
Copy link
Contributor

Description

When trying to start a new environment using wp-env, the CLI issues the following error:

mysqlcheck: Got error: 1045: Access denied for user 'username_here'@'172.18.0.5' (using password: YES) when trying to connect

This issue is not specific to working locally using this repository, but exists wherever @wordpress/env is used.

Step-by-step reproduction instructions

  1. Destroy your local environment npm run wp-env destroy
  2. Re-provision: npm run wp-env start

Expect to see the errors. Should you not see the error, make sure your docker images are updated to the latest.

Quick Debugging

  • username_here was implemented in the WordPress docker image fairly recently (docker-library/wordpress@8f5bcc1#diff-7f28a0f62019f2d8b061638e8c3aea207404c1499f1c9241db3216fadd8f4530)
  • the wp-config.php in the WordPress container matches the default config in the PR listed above.
  • the wp-config.php includes the getenv_docker function that looks for a local env_FILE that does not exist in the WordPress container.
  • When looking at the container using the docker desktop app, I see No 'wp-config.php' found in /var/www/html, but 'WORDPRESS_...' variables supplied; copying '/usr/src/wordpress/wp-config-docker.php' (WORDPRESS_DB_NAME)

Environment Info

Relevant NPM packages

├─┬ @wordpress/[email protected]
│ ├── [email protected] deduped
│ ├── [email protected]
│ ├── [email protected]
│ ├── [email protected]
│ ├── [email protected]
│ ├── [email protected] deduped
│ ├── [email protected]
│ ├── [email protected]
│ ├── [email protected] deduped
│ ├── [email protected]
│ ├── [email protected]
│ └── [email protected]

WordPress information

trunk@647a41c

@StevenDufresne StevenDufresne added the [Tool] Env /packages/env label Mar 11, 2021
@talldan
Copy link
Contributor

talldan commented Mar 11, 2021

What I don't know is how wp-env previously defined the DB username and password values. (cc @noahtallen, @noisysocks).

Struggling to find a reference to anything like that. Not sure if the docker container is supposed to work without these specified. If so, it may be an upstream issue.

@StevenDufresne StevenDufresne changed the title Env: Access denied for user 'username_here'@'X.X.X.X'. errors running wp-env start. Env: Access denied for user 'username_here'@'X.X.X.X' error running wp-env start. Mar 11, 2021
@StevenDufresne
Copy link
Contributor Author

Also noting that the feature added in the WordPress image was un-betaed yesterday.

docker-library/wordpress@fb920c6

@noisysocks
Copy link
Member

What I don't know is how wp-env previously defined the DB username and password values. (cc @noahtallen, @noisysocks).

IIRC these were omitted because the wordpress image defaulted to user = 'root', password = '' which is what the mysql image also defaults to.

@youknowriad
Copy link
Contributor

Tried setting explicitely the environoment variables for user and password to "root" and "" in the docker-compose.yml generated by wp-env and for some reason I didn't manage to make it work

@pierlon
Copy link
Contributor

pierlon commented Mar 11, 2021

The wordpress image was previously creating the WordPress database if it did not already exist.

@youknowriad
Copy link
Contributor

Thanks for the hint @pierlon this helped me figure out a potential fix here #29770

@pierlon
Copy link
Contributor

pierlon commented Mar 11, 2021

@youknowriad I've also created a PR that reintroduces the feature of creating the database on container startup: docker-library/wordpress#575.

@noahtallen
Copy link
Member

Resolved in #29800. This fix will need to be pushed to npm before anyone outside of gutenberg will see it, and I'm not sure when that will happen.

See #29800 (review) for possible follow-up tasks.

iandunn pushed a commit to WordPress/Learn that referenced this issue May 31, 2021
Upgrading `wp-env` to latest version fixes issues related to newer WordPress docker images using different credentials. 

For more information see WordPress/gutenberg#29752
Pinkle-pash added a commit to Pinkle-pash/Learn that referenced this issue Dec 5, 2024
Upgrading `wp-env` to latest version fixes issues related to newer WordPress docker images using different credentials. 

For more information see WordPress/gutenberg#29752
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Status] In Progress Tracking issues with work in progress [Tool] Env /packages/env
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants