MySql Docker container refuses to connect to Microsoft Azure (Mac) - mysql

First of all - hello. Secondly, I just downloaded Docker and got it to run MySql on my Mac. It has never connected before and I am trying to learn how to make databases.
Everything was running smoothly - I opened Docker and ran my container (it is running), but when I tried to connect with Microsoft Azure, it persistently refused to do so.
Since my password was strong enough to fill the criteria, I checked the port and it is indeed 1433.
So I started to use every variation I could think of in username, just to see what happens.
Nothing. No connection. I read it could be the firewall, but all the instructions I found were Windows and other applications.
Can anyone here point me in the right direction? It seems such a pathetic hill to die on.

docker run --name <your-mysql-name> -e MYSQL_ROOT_PASSWORD=<your-sql-password> -p <host-port>:<container-port> -d mysql
You'll need to expose / publish the port (-p command), if not MySQL cannot be accessed by external sources.
For example:
docker run --name test-mysql -e MYSQL_ROOT_PASSWORD=somepassword -p 3306:3306 -d mysql

The user name is "sa". I found it on a blog and tried it out. It worked.

Related

How to connect remotely to sql database in docker container?

newbie here.
I have a docker container with a mysql server on it. I want to be able to work on it on different pc.
Following a guide I did these steps:
1)create a db and an account with all privileges
2)got the machine ip throudh powershell with:
"docker inspect -f '{{range.NetworkSettings.Networks}}{{.IPAddress}}{{end}}' YOUR_CONTAINER_NAME"
3)tried to connect to my server in workbench
It didn't work but I don't really know what I'm doing.
Anybody can give me a step by step guide to follow? Thank you
Add port mapping using docker run -p and modify inbound firewall rules in the PC where container is running to allow traffic on the port from another machine in same network

initialize mysql in host and access in docker container

I am creating very simple database like
mysql -u root -e "CREATE DATABASE IF NOT EXISTS example"
and I want to access it in the doker container like
"mysql://root#localhost/example"
both host and conteiner is ubuntu machine
I suppose answer is very simple but I got lost - Thanks !
With docker, all the stuff can be accessible with localhost. But you need to expose the service to a local port.
So with -p 80:80 in your run command, you will be able to expose the port 80 on your container, to your local port 80.
Docker run doc
I hope it will help you!

Docker Can't connect to MySql server on 0.0.0.0 (10049)

Using latest Docker desktop and mariadb/latest image I have created a container, which runs OK, local MySQL command work successfully.
BUT whatever I try to connect to the container with HeidiSQL, I get
"Can't connect to MySql server on 0.0.0.0 (10049)"
I think I have read at least 50 different "solutions" here and on other sites, but whatever I do, I get the same error, whatever IP I use.
Running Windows 10 Pro freshly updated, as with latest Docker desktop.
Created the container with
docker run -p 3306:3306 --name demo -e MYSQL_ROOT_PASSWORD=xyz -d mariadb/server --log-bin --binlog-format=MIXED
Changed binding in my.cnf to 0.0.0.0
Granted all rights to 'root'#'%' thru local mysql cli.
Restarted the whole shebang NUMEROUS times
Tried connections on 0.0.0.0, 127.0.0.1, localhost, 172.17.0.2, etc, etc, etc.
"docker ps" says PORT: "3306/tcp"
Using bash in the container, I can reach out and apt update etc, etc.
I'm out of options. Is there a kind guru out there with a new suggestion?

Docker instance of MySQL is not setting root password -- any login without a password is allowed

I set up a new computer running macOS 10.14.5 and Docker Desktop community 2.0.0.3 (31259) and I noticed that my MySQL container wasn't being created properly. This is the command that I had run on my previous computer:
docker run --name virtual-mysql -p 3306:3306 -e MYSQL_ROOT_PASSWORD=mypassword -d mysql:5.7.22
That worked: it would properly set the root password. But on the new computer, when I run that command, the root password is NOT set. I can log in as the root user, but only if I leave the password blank. Only the root user can create a database.
But more curiously, I can specify ANYTHING as the user, e.g. asdf and successfully log in (!!!). When I log in as a non-existent user, I can only view the information_schema and I cannot create a database, however -- I get an error: Access denied for user ''#'localhost' to database 'asdf' -- which suggests that perhaps my client isn't sending the login credentials correctly (I am using Sequel Pro 1.1.2 as my MySQL client).
Can someone explain this strange behavior?
After some helpful nudging, I figured out where this was going off the rails.
First problem: one of the apps I installed had installed an instance of MySQL onto the host OS. I didn't notice it because I had done which mysql from an open Terminal window that didn't have its PATH updated.
Second problem: mysqld kept running a process that bound to port 3306.
I didn't notice this until running lsof -Pnl +M -i4 | grep 'LISTEN'lsof -Pnl +M -i4 | grep 'LISTEN' revealed it. I had my suspicions when I could bring up new dockerized instances bound to other ports.
So the solution was to THOROUGHLY delete mysql (and mysqld), then REBOOT to shake any dangling connections. Once I had done that, my dockerized versions ran fine.

Unable to connect Sequel Pro with mysql docker container

I feel like this should be an easy fix but I can't seem to figure this out. I just installed docker and ran:
docker run -d --name test-mysql -p 3306:3306 -e MYSQL_ALLOW_EMPTY_PASSWORD=yes -e MYSQL_DATABASE=test mysql
I did this to create my first container. After that I opened sequel pro an typed in the correct things to connect to the database. I got this...
Unable to connect to host 127.0.0.1, or the request timed out.
Be sure that the address is correct and that you have the necessary privileges, or try increasing the connection timeout (currently 10 seconds).
MySQL said: Host '172.17.0.1' is not allowed to connect to this MySQL server
Does anyone know how to fix this?