If you just installed MySQL image on Docker and then try to access the container and run MySQL command and you get the below 1045 (2800) error,

% mysql
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)
% mysql -u root -p
Enter password:
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)
Fix:
You need to go to Docker desktop and check for the logs for the MySQL container, you should see the generated root password,
[Entrypoint] Database initialized
mysqld will log errors to /var/lib/mysql/b05e275b7577.err
mysqld is running as pid 68
Warning: Unable to load '/usr/share/zoneinfo/iso3166.tab' as time zone. Skipping it.
Warning: Unable to load '/usr/share/zoneinfo/leapseconds' as time zone. Skipping it.
Warning: Unable to load '/usr/share/zoneinfo/tzdata.zi' as time zone. Skipping it.
Warning: Unable to load '/usr/share/zoneinfo/zone.tab' as time zone. Skipping it.
Warning: Unable to load '/usr/share/zoneinfo/zone1970.tab' as time zone. Skipping it.
[Entrypoint] GENERATED ROOT PASSWORD: asdQ52ERv=;13AB@j*o=Y2O2j.pl6?@2
You can also access the logs using command: docker logs container_name
Now copy this MySQL root password and run the MySQL command again,
% mysql -uroot -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 30
Server version: 8.0.30
Copyright (c) 2000, 2022, Oracle and/or its affiliates.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
Provide Feedback For This Article
We take your feedback seriously and use it to improve our content. Thank you for helping us serve you better!
😊 Thanks for your time, your feedback has been registered!
Comments & Discussion
Facing issues? Have questions? Post them here! We're happy to help!