Access denied for user 'root'@'localhost' in the mysql docker

user824624 :

Running a docker mysql container in the following command

docker run -it --name mysql  -e MYSQL_ROOT_PASSWORD=123456 mysql

then docker creates a running mysql container with logs as

2020-07-23 09:39:19+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 8.0.21-1debian10 started.
2020-07-23 09:39:20+00:00 [Note] [Entrypoint]: Switching to dedicated user 'mysql'
2020-07-23 09:39:20+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 8.0.21-1debian10 started.
2020-07-23 09:39:20+00:00 [Note] [Entrypoint]: Initializing database files
2020-07-23T09:39:20.408751Z 0 [Warning] [MY-011070] [Server] 'Disabling symbolic links using --skip-symbolic-links (or equivalent) is the default. Consider not using this option as it' is deprecated and will be removed in a future release.
2020-07-23T09:39:20.408909Z 0 [System] [MY-013169] [Server] /usr/sbin/mysqld (mysqld 8.0.21) initializing of server in progress as process 42
2020-07-23T09:39:20.424771Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started.
2020-07-23T09:39:22.342488Z 1 [System] [MY-013577] [InnoDB] InnoDB initialization has ended.
2020-07-23T09:39:26.473394Z 6 [Warning] [MY-010453] [Server] root@localhost is created with an empty password ! Please consider switching off the --initialize-insecure option.
2020-07-23 09:39:35+00:00 [Note] [Entrypoint]: Database files initialized
2020-07-23 09:39:35+00:00 [Note] [Entrypoint]: Starting temporary server
mysqld will log errors to /var/lib/mysql/da5f3f1ae045.err
mysqld is running as pid 91
2020-07-23 09:39:37+00:00 [Note] [Entrypoint]: Temporary server started.
Warning: Unable to load '/usr/share/zoneinfo/iso3166.tab' as time zone. Skipping it.
Warning: Unable to load '/usr/share/zoneinfo/leap-seconds.list' 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.

2020-07-23 09:39:56+00:00 [Note] [Entrypoint]: Stopping temporary server
2020-07-23 09:39:59+00:00 [Note] [Entrypoint]: Temporary server stopped

2020-07-23 09:39:59+00:00 [Note] [Entrypoint]: MySQL init process done. Ready for start up.

2020-07-23T09:39:59.908211Z 0 [Warning] [MY-011070] [Server] 'Disabling symbolic links using --skip-symbolic-links (or equivalent) is the default. Consider not using this option as it' is deprecated and will be removed in a future release.
2020-07-23T09:39:59.910343Z 0 [System] [MY-010116] [Server] /usr/sbin/mysqld (mysqld 8.0.21) starting as process 1
2020-07-23T09:39:59.945124Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started.
2020-07-23T09:40:00.579927Z 1 [System] [MY-013577] [InnoDB] InnoDB initialization has ended.
2020-07-23T09:40:00.969050Z 0 [System] [MY-011323] [Server] X Plugin ready for connections. Bind-address: '::' port: 33060, socket: /var/run/mysqld/mysqlx.sock
2020-07-23T09:40:01.137873Z 0 [Warning] [MY-010068] [Server] CA certificate ca.pem is self signed.
2020-07-23T09:40:01.138424Z 0 [System] [MY-013602] [Server] Channel mysql_main configured to support TLS. Encrypted connections are now supported for this channel.
2020-07-23T09:40:01.145079Z 0 [Warning] [MY-011810] [Server] Insecure configuration for --pid-file: Location '/var/run/mysqld' in the path is accessible to all OS users. Consider choosing a different directory.
2020-07-23T09:40:01.233430Z 0 [System] [MY-010931] [Server] /usr/sbin/mysqld: ready for connections. Version: '8.0.21'  socket: '/var/run/mysqld/mysqld.sock'  port: 3306  MySQL Community Server - GPL.

Trying to access the container with

mysql -h localhost -u root -p

it asks for the password, using 123456 as the password fails; using empty password also fails.

ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)
Adiii :

docker exec -it mysql mysql -uroot -p, then a prompt is out to input the password with 123456, then It can successfully get access to the mysql command line. however why I can't use tableplus

From the comment above it's verified that you are able to access the mysql server inside the container, so the issue with tableplus not the container root password.

Just publish the port and it should work,

docker run -it -p 3306:3306 --name mysql  -e MYSQL_ROOT_PASSWORD=123456 mysql

Also, it seems like tableplus connecting with host MySQL instead of container one as container did not publish the port in your case so it trying to connect somewhere else.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

mysql error Access denied for user 'root'@'localhost'

MySQL Error: : 'Access denied for user 'root'@'localhost'

MYSQL_ROOT_PASSWORD is set but getting "Access denied for user 'root'@'localhost' (using password: YES)" in docker container

mysql-docker-container - ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)

Maria DB docker Access denied for user 'root'@'localhost'

Access denied for user 'root '@'localhost' " when connecting to mysql

MySQL said: Access denied for user 'root'@'localhost' (using password: NO)"

How to query mysql Kubernetes pod? Access denied for user 'root'@'localhost'

Rails app denied access to mysql for user root @ localhost

mysql_connect(): Access denied for user 'root'@'localhost'

Mysql: Access denied for user 'root'@'localhost' right after installation on macOS

mysql how to fix Access denied for user 'root'@'localhost'

mysql (mariadb) ERROR 1698 (28000): Access denied for user 'root'@'localhost'

ERROR 1698 (28000): Access denied for user 'root'@'localhost, on MySQL 5.7

How to Solve MySQL Error: Access denied for user root@localhost

NodeJS/mySQL - ER_ACCESS_DENIED_ERROR Access denied for user 'root'@'localhost' (using password: YES)

docker-compose: Unable to connect app service to mysql database, receive "Error: Access denied for user 'root'@'localhost' (using password: YES)

Access denied for user 'root'@'localhost' from servlet

Access denied for user 'root'@'localhost' to database 'drupal'

Access denied for user root@localhost

NodeJS/mySQL - ER_ECCESS_DENIED_ERROR Access denied for user 'root'@'localhost' (using password: YES)

MySQL: Access denied for user 'userName'@'localhost'

mysql_query(): Access denied for user ''@'localhost'

Django - MySQL: 1045 Access Denied for 'user'@'localhost'

Mysql PHP Access denied for user ''@'localhost' to database

Brew mysql ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)

ASP.NET MVC MySQL Access denied for user 'root'@'localhost' (using password: NO)

mysql -v ERROR 1045 (28000): Access denied for user root'@'localhost' (using password: NO)

Locall MySQL DB login Error : Access denied for user 'root'@'localhost' (using password: YES)