0

hi i'm new in docker and for practice created this project but when it's run with docker compose shows me below error:

wordpress     | MySQL Connection Error: (1045) Access denied for user 'user1'@'172.19.0.4' (using password: NO)

docker-compose.yml:

version: '3.9'

services: 
  db:
    image: mysql:latest
    container_name: mysql
    restart: always
    command: "--default-authentication-plugin=mysql_native_password"
    environment: 
      MYSQL_ROOT_PASSWORD: mjs
      MYSQL_DATABASE: wpdb
      MYSQL_USER: user1
      MYSQL_PASSWORD: mjs

  wordpress:
    image: wordpress
    container_name: wordpress
    restart: always
    volumes: 
      - ./wp-content:/var/www/html/wp-content
    environment: 
      WORDPRESS_DB_HOST: db:3306
      WORDPRESS_DB_NAME: wpdb
      WORDPRESS_DB_USER: user1
      WORDPRESS_DB_PASSWROD: mjs
    ports: 
      - 8080:80
      - 443:443
    depends_on: 
      - db

  phpmyadmin:
    image: phpmyadmin:latest
    restart: always
    ports: 
      - 3333:80
    environment: 
      PMA_HOST: db
      MYSQL_ROOT_PASSWORD: mjs

I searched for stackoverflow but found nothing.

Thank you for your help

2
  • 1
    WORDPRESS_DB_PASSWORD should have the O before the R. Is this spelled correctly in your local file? Misspelling it could cause Wordpress to attempt connecting without a password (which you see in the diagnostic you quote). Commented Mar 10, 2021 at 17:42
  • Thank you for your attention and guidance Commented Mar 10, 2021 at 19:28

1 Answer 1

1

If you are not defining your db volume data is not persisting on restart. Just btw. Furthermore it's a good practice to pin your image to a version like mysql:5.7. Did you try that one here? https://docs.docker.com/compose/wordpress/

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.