Access denied for user 'root'@'172.18.0.3'

2,437 views
Skip to first unread message

Chuck Henry

unread,
Oct 21, 2021, 8:20:13 AM10/21/21
to archipela...@googlegroups.com
Hey everybody!


I've set up an AWS Ubuntu 20.04.3 LTS instance. And so far everything has gone well... right up until this step:

docker exec -ti esmero-php bash -c "cd web;../vendor/bin/drush -y si --verbose config_installer  config_installer_sync_configure_form.sync_directory=/var/www/html/config/sync/ --db-url=mysql://root:[MYPASSWORD]@esmero-db/drupal8 --account-name=admin --account-pass=[MY_ADMIN_PASSWORD] -r=/var/www/html/web --sites-subdir=default --notify=false install_configure_form.enable_update_status_module=NULL install_configure_form.enable_update_status_emails=NULL;drush cr;chown -R www-data:www-data sites;"

I specified in deploy/ec2-docker/.env the [MYPASSWORD] and the [MY_ADMIN_PASSWORD] and replaced them in the above command as the instructions noted. However when I run the command I get the following response:

[info] Executing: command -v mysql
 [info] Executing: mysql --defaults-file=/tmp/drush_DDPmpL --database=drupal8 --host=esmero-db --silent -A < /tmp/drush_IjClLO
 
You are about to:
 * CREATE the 'drupal8' database.

 // Do you want to continue?: yes.

 [info] Sites directory sites/default already exists - proceeding.
 [info] Executing: mysql --defaults-file=/tmp/drush_GlGnHG --database=drupal8 --host=esmero-db --silent -A < /tmp/drush_aJnmAh
 [info] Executing: mysql --defaults-file=/tmp/drush_LfMcdc --database=information_schema --host=esmero-db --silent -A < /tmp/drush_iaiOhk
 [warning] Failed to drop or create the database. Do it yourself before installing. ERROR 1045 (28000): Access denied for user 'root'@'172.18.0.3' (using password: YES)

I've bolded the part I find concerning. The rest of the output looks like drupal failing to install because it can't write to the db.

I can get into sql just find via: docker exec -ti esmero-db bash -c "mysql -u root -p" and in an attempt to get this puppy working I've created a 'root'@'172.18.0.3' account with all privileges including 'grant'. But that doesn't seem to work either. So now I'm wondering if the sql is bound to just localhost and needs to be bound to 0.0.0.0 all? Being a docker noob I don't have the first idea how'd I'd change that or even if that'd help! I'm familiar with mysql administration but the docker bit spices it up a bit!

Any advice or direction would be appreciated!  Thanks in advance!

Chuck Henry
Integrated Technologies Coordinator
Northern New York Library Network
chu...@nnyln.org :: nnyln.org
Office: 315-265-1119 Ext 3
PGP Fingerprint: 09A7 2332 C194 71FD D90E  78E7 71D6 FAA7 C5ED 7F8F

dp...@metro.org

unread,
Oct 21, 2021, 12:28:30 PM10/21/21
to archipelago commons
Hi Chuck, nice to read you!

Ok, I have a few pointers but because I can not see (and that is ok, its secret!) your .env i will need you to do some tests. Since we have been doing this a lot and the instructions do work my guess is that the password either has some strange (for a bash command line) characters or has an invisible character (like a tab or an extra space) at the end of start.
1.- Double check your .env. Make sure the line ends with the last character of the password.
2.- Check that you are not using (without escaping on the actual drush command or single quoting) any of these https://stackoverflow.com/questions/46663630/mysql-command-line-password-with-special-characters-is-not-working. If you are using that you need to escape the password as explained in that ever handy stack overflow post.
3.- Test direct access with the current password to the esmero-db container. the IP address you see there 172.18.0.3 is not the one your host machine can access. Its an internal, between containers address (docker network) for esmero-db. Resolves, inside esmero-php, esmero-db to 172.18.0.3. If you log into that container you can do a 

host esmero-db and you will the internal mapping.

To test Mysql access from your host/server do this

docker exec -ti esmero-db mysql -u root -p

and type your password

OR

docker exec -ti esmero-db mysql -u root -p'super"·$@!$####??-secure-password' where password is ·$@!$####??-secure-password

(notice the lack of space between the -p and the first single quote)

.env file is loaded on docker-compose up, so if you make a change there, do a docker-compose down first, then a docker-compose up -d, or a docker-compose stop and then a docker-compose start (may work, I do always do a down--up combo but I do not know everything)

You can also check the db logs when doing this by issuing this command

docker logs -f esmero-db

let us know how that goes!

Hugs


Diego


Chuck Henry

unread,
Oct 25, 2021, 9:37:53 AM10/25/21
to dp...@metro.org, archipelago commons
Diego! I'm back in business!

So my mysql password contained an $. Duh. If I'd thought about it for 2 seconds I wouldn't have used any special characters in the password! Bad mysql mojo right there!

I couldn't get any form of escaping the character or the password to work in that command so I did this the hard way (documented here for any similarly wayward fools to follow!):
  • logged into mysql using: docker exec -ti esmero-db bash -c "mysql -u root -p"
  • while in mysql:
    • alter user 'root'@'localhost' identified by 'NEWPASSWORD';
    • flush privileges;
    • exit;
  • docker-compose down
  • Changed the mysql password in the .env file to NEWPASSWORD
  • docker-compose up -d
  • Ran the command again with the NEWPASSWORD inserted! And boom it works!
Onwards and upwards!  Thanks Diego!

Chuck Henry
Integrated Technologies Coordinator
Northern New York Library Network
chu...@nnyln.org :: nnyln.org
Office: 315-265-1119 Ext 3
PGP Fingerprint: 09A7 2332 C194 71FD D90E  78E7 71D6 FAA7 C5ED 7F8F

--
You received this message because you are subscribed to the Google Groups "archipelago commons" group.
To unsubscribe from this group and stop receiving emails from it, send an email to archipelago-com...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/archipelago-commons/e546d3cb-1e2b-435c-82a9-c9ac2d2483a7n%40googlegroups.com.

Diego Pino

unread,
Oct 25, 2021, 9:43:46 AM10/25/21
to Chuck Henry, archipelago commons

Wonderful news! Have been there and have used $ and have spend hours trying to debug so understand the frustration. Sadly $ can only be quoted or double escaped when used inna shell
Command and tbh can’t remember how without searching the wide web!

Hugs and happy archipelago-ing
--
Diego Pino Navarro
Digital Repositories Developer
Metropolitan New York Library Council (METRO)
Reply all
Reply to author
Forward
0 new messages