T
T
thatmaniscool2022-04-21 21:39:19
MySQL
thatmaniscool, 2022-04-21 21:39:19

How to connect to mysql database in docker?

Created a container with a mysql database and decided to use the heidisql GUI for convenience.
Step by step:
1. I create a user with all rights.

CREATE USER 'lost'@'%' IDENTIFIED BY '123';
GRANT ALL PRIVILEGES ON *.* TO 'lost'@'%';
FLUSH PRIVILEGES;

2. I make sure that the user with the specified name has been created.
+------------------+-----------+
| user             | host      |
+------------------+-----------+
| lost             | %         |
| root             | %         |
| mysql.infoschema | localhost |
| mysql.session    | localhost |
| mysql.sys        | localhost |
| root             | localhost |
+------------------+-----------+
6 rows in set (0.00 sec)

3. Next, I go to the container and in order to identify its ip address and port.
6261a3e9b3ed2784380827.png
4. I open heidisql and enter the specified data.
6261a47d634b3253564201.png
5. But it gives an error that it cannot connect.
6261a4c59e7b7604822912.png
I've tried everything, but haven't been able to find a solution yet.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dmitry, 2022-04-21
@thatmaniscool

Port 3306 opened outside?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question