A
A
apaicer2021-03-01 13:37:47
MySQL
apaicer, 2021-03-01 13:37:47

CMS doesn't see MySQL in Docker container?

I set out to launch the site when MySQL is in the Docker container.

Available:
Docker container:

CONTAINER ID   IMAGE                    COMMAND                  CREATED        STATUS                  PORTS                                 NAMES
38890df7ee0b   mysql/mysql-server:5.7   "/entrypoint.sh mysq…"   13 hours ago   Up 13 hours (healthy)   33060/tcp, 127.0.0.1:3310->3306/tcp   mysql


The problem is that the CMS does not see it as localhost. (see screenshot)
603cc4499b372115222507.png
603cc4522238a799174856.png

1635 line:
mysqli_real_connect( $this->dbh, $host, $this->dbuser, $this->dbpassword, null, $port, $socket, $client_flags );


All privileges have been granted.

mysql> show grants for 'mto'@'localhost';
+------------------------------------------------------+
| Grants for [email protected]                             |
+------------------------------------------------------+
| GRANT USAGE ON *.* TO 'mto'@'localhost'              |
| GRANT ALL PRIVILEGES ON `mto`.* TO 'mto'@'localhost' |
+------------------------------------------------------+
2 rows in set (0.00 sec)

mysql> show grants for 'mto'@'%';
+----------------------------------------------+
| Grants for mt[email protected]%                             |
+----------------------------------------------+
| GRANT USAGE ON *.* TO 'mto'@'%'              |
| GRANT ALL PRIVILEGES ON `mto`.* TO 'mto'@'%' |
+----------------------------------------------+
2 rows in set (0.00 sec)


In this case, if you connect like this, everything is ok:

mysql -umto -h127.0.0.1 -P3310 -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.


And if you do not explicitly specify the port, the connection fails

mysql -umto -h127.0.0.1:3310 -p
Enter password: 
ERROR 2005 (HY000): Unknown MySQL server host '127.0.0.1:3310' (2)


Tell me how to make friends?

I intentionally want only MYSQL in the docker, I don’t offer to throw everything into containers.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
index0h, 2021-03-01
@index0h

It looks like your actual connection is not through localhost, but on the ip of the container.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question