Docker Community Forums

Share and learn in the Docker community.

Laradock: Cannot access mysql from host

Hello,

i try to access the mysql-Server from the Host.
I’ve build my environment with laradock following the introduction

composer inspect for the mysql container shows

"NetworkSettings": {
            "Bridge": "",
            "SandboxID": "cf11cfa2faa722bbc91056e4af60d4cbc5e161685a18e71850bfe3f21ec639e6",
            "HairpinMode": false,
            "LinkLocalIPv6Address": "",
            "LinkLocalIPv6PrefixLen": 0,
            "Ports": {
                "3306/tcp": [
                    {
                        "HostIp": "0.0.0.0",
                        "HostPort": "33060"
                    }
                ],
                "33060/tcp": null
            },
            "SandboxKey": "/var/run/docker/netns/cf11cfa2faa7",
            "SecondaryIPAddresses": null,
            "SecondaryIPv6Addresses": null,
            "EndpointID": "",
            "Gateway": "",
            "GlobalIPv6Address": "",
            "GlobalIPv6PrefixLen": 0,
            "IPAddress": "",
            "IPPrefixLen": 0,
            "IPv6Gateway": "",
            "MacAddress": "",
            "Networks": {
                "laradock_backend": {
                    "IPAMConfig": null,
                    "Links": null,
                    "Aliases": [
                        "bdc7102e825f",
                        "mysql"
                    ],
                    "NetworkID": "f20363b5879329b962d0e637ac9c4018ad46172895233f98a0fc72309ce23eac",
                    "EndpointID": "f4a2548fdca36676cb8a1de12a4c58598d93afad418a3784945e37e0fcc0897c",
                    "Gateway": "172.24.0.1",
                    "IPAddress": "172.24.0.3",
                    "IPPrefixLen": 16,
                    "IPv6Gateway": "",
                    "GlobalIPv6Address": "",
                    "GlobalIPv6PrefixLen": 0,
                    "MacAddress": "02:42:ac:18:00:03",
                    "DriverOpts": null
                }
            }
        }

So i supose the ip to used is 172.2.0.3
Now i try to access the server with workbench, but neither the ip upon or 127.0.0.1 give me the access. Always returned the same error:

Can’t connect to MySql server on ‘172.24.0.3’ (10060)
Can’t connect to MySql server on ‘127.0.0.1’ (10060)

The artisan migrate works fine from the workspace, so, the database is available…

Which ip i’ve tu use do connect with the server?

Opa @rammi22, também passei por esse problema e depois de muito pesquisar instanciei o phpmyadmin para poder testar com mais velocidade e percebi que o link para o phpmyadmin era localhost:8081… Dai fui no meu workbench e coloquei no host em vez do IP 172.24.0.3 coloquei “localhost” a porta que configurei e o usuario e senha “root” e pegou… kkkk tão simples e eu quebrando a cabeça. Espero que ajude você e outras pessoas!

Open up the file under ‘etc/mysql/my.cnf’
Check for: …
Now access the MySQL Database on your actual server (say your remote address is 123.123.123.123 at port 3306 as user ‘root’ and I want to change permissions on database ‘dataentry’. …
sudo service mysqld restart.