Jump to content
We're Hiring! Full Stack Developer ×

Unable to login to mysql container after installing, should it be this confusing?


arretx

Recommended Posts

I first tried installing mysql from the Docker repository as explained on a few different youtube videos, but that failed every time.  So, I went with the Bungy's Repository version, installed it with what I thought was a simple process, but after the container fires up, in the console and from any SQL tools, I'm denied access.

 

In console if I type `mysql -u root -p` then enter the root password as I defined it during installation, I'm given the big "Access denied for user 'root'@'localhost' (using password: YES)"

 

Stumped.  What am I doing wrong?

Link to comment

I'm definitely not a SQL guy (always used MariaDB for whatever has required a SQL db in the past), but I find it interesting that even on the sample installation method listed on the registry for MySQL

docker run --name some-mysql -e MYSQL_ROOT_PASSWORD=my-secret-pw -d mysql:tag

The same error results.

Link to comment

Working for me, one thing to note is you can only set the root password the first time, maybe some volume/appdata folder needs to be nuked?

 

Run command used for test

docker run --name some-mysql -e MYSQL_ROOT_PASSWORD=my-secret-pw -d mysql:latest

 

Successful login using ENV set in template / run cmd

root@fortytwo:~# docker exec -it some-mysql sh -c 'exec mysql -uroot -p"$MYSQL_ROOT_PASSWORD"'
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 13
Server version: 8.0.28 MySQL Community Server - GPL

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.

mysql> SHOW DATABASES;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| sys                |
+--------------------+
4 rows in set (0.02 sec)

mysql> EXIT
Bye

 

Successful login via CLI passing password

root@fortytwo:~# docker exec -it some-mysql bash
root@a6a52d23fe48:/# mysql -uroot -pmy-secret-pw
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 14
Server version: 8.0.28 MySQL Community Server - GPL

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.

mysql> SHOW DATABASES
    -> ;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| sys                |
+--------------------+
4 rows in set (0.01 sec)

mysql> exit
Bye

 

Successful login via CLI entering password manually

root@fortytwo:~# docker exec -it some-mysql bash
root@a6a52d23fe48:/# mysql -uroot -p            
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 15
Server version: 8.0.28 MySQL Community Server - GPL

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.

mysql> SHOW DATABASES;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| sys                |
+--------------------+
4 rows in set (0.00 sec)

mysql> 

 

Edited by tjb_altf4
Link to comment
  • 1 year later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...