SQLSTATE[HY000] [1045] Access denied for user 'user'@'172.23.0.2' (using passwor d: YES)

98 Views Asked by At

I recently needed to delete my Docker container and start docker-compose over to fix something in my yaml file for my Drupal project...

Anyhoo, the containers seemed to be running normally with the correct port... I can also log into mysql normally after installing it on sudo (I'm on Ubuntu).

But for some reason, I run drush commands and see this:

SQLSTATE[HY000] [1045] Access denied for user 'user1'@'172.23.0.2' (using password: YES) 

More info:

  • When I change user's name in my settings.php or remove the password I get the same error.

  • I tried creating the user and granting privileges in mysql and that did nothing.

As you can see in the above error, the IP created by Docker isn't acknowledged by Drush. I forgot why it seemed to work the last time but not now.

Here's my docker yml file.

  theme:
    image: docwebsolutions/doc_drupal:php8.1-v3
    volumes:
      - ~/Users/USER/web_theme:/var/www/docker_platform:delegated
   #   - /path/to/.ssh:/root/.ssh:ro  
    entrypoint: /root/entrypoint.sh --dbusername=user1 --dbpassword=admin --dbname=db1 --dbhost=db --dbport=3306 --project=web_theme [email protected] [email protected] --adminpassword=admin --drupalversion=9 --mariadbpassword=admin
    ports:
      - 443
      - 80
    depends_on:
      - db
    links:
      - db

#############################################################
##  External Services                                      ##
#############################################################
  db:
    image: mariadb
    restart: always
    environment:
      MYSQL_ROOT_PASSWORD: admin1
  portainer:
    image: portainer/portainer
    ports:
      - 9000
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock
    command: -H unix:///var/run/docker.sock --no-auth

And my settings.php file:

$databases['default']['default'] = array (
  'database' => 'db1',
  'username' => 'user1',
  'password' => 'admin',
  'prefix' => '',
  'host' => 'db',
  'port' => '3306',
   'namespace' => 'Drupal\\Core\\Database\\Driver\\mysql',
  'driver' => 'mysql',
 'autoload' => 'core/modules/mysql/src/Driver/Database/mysql/',
);
0

There are 0 best solutions below