how to change mysql connection port in docker adminer settings - mysql

I have a docker image with mysql which has an internal port of 3307.
I'm also trying to run the container for adminer, but when it starts it tries to connect to the standard port 3306, is there any variable that would indicate the port number to connect to?

You can map the 3306 port of the host and the 3307 port of the container, so that you can connect by connecting the IP:3306 of the host. Of course, you can change the my.cnf file of the container and change the port to 3306, which can also be solved.

Related

Connect to remote mysql server from localhost docker container

I have doctrine config:
doctrine:
dbal:
driver:pdo_mysql
url:"mysql://%database_user%:%database_password%#%database_host%:%database_port%/%database_name%"
Where database_user is root, password is root user password (re-checked), host is my server ip address, port is 3306 and name is my db name.
When I use these from workbench I can connect but from running docker container for php and nginx. And this config, I get connection refused.
Do I need somehow to allow connections from localhost? Why is it working from workbench then?

How to connect to Docker MySQL databse from a different virtual machine

I have two EC2 instances.
vm1 - has mysql server running as a Docker container
vm2 - has mysql client installed.
Now I want to connect from vm2 to the mysql container running in vm1. In vm1, the container is exposed 3306 to the container port 3306
I tried first telnetting the port as:
telnet <ip-of-vm1> 3306
and I get the below error:
Trying 10.128.15.6...
telnet: Unable to connect to remote host: Connection refused
I even allowed the firewall rules to allow all inboud. And mysql container running without any errors.
Can someone help me on this?

what is the port 33060 for mysql server ports in addition to the port 3306

background purpose: I want to restrict inbound connection to MYSQL server only for specific host by setting inbound rules of windows firewall.
MYSQL server port is open on 3306.
However, when I open firewall setting, I can see two ports are opened on 3306 and 33060 as follows:
what is that? Should I restrict 33060 as well?
The port for X Protocol (mysqlx_port), supported by clients such as MySQL Shell, MySQL Connectors and MySQL Router, is calculated by multiplying the port used for classic MySQL protocol by 10. For example if the classic MySQL protocol port is the default value of 3306 then the X Protocol port is 33060.
See MySQL Port Reference Tables for more information.
The MySQL X service, is listening on all interfaces, by default over localhost, on TCP port 33060 and clients can connect to it through x protocol. So you need to restrict it for specific host to ban it to connect through x protocol. I suggest use it just for localhost.
You can see open ports by mysql through the following command:
sudo lsof -i -P -n | grep 3306

How to change Docker Mysql container connection port?

I'm working with node, docker, mysql and sequelize and am trying to connect sequelize to mysql container running on docker. It will only connect through port 3306 despite me having changed the "ports" to 3308-3308. When i look up the running containers i get the following for the mysql database:
ticketgo_database_1 docker-entrypoint.sh mysqld Up 3306/tcp,
0.0.0.0:3308->3308/tcp
Which explains why it can only connect to port 3306 but I need to change the connection port from 3306 since that port is busy on my computer. How can i do that?
Mysql container:
database:
image: mysql
environment:
MYSQL_DATABASE: "ticketgo"
MYSQL_ROOT_PASSWORD: "pass"
volumes:
- "./sql:/docker-entrypoint-initdb.d"
ports:
- "3308:3308"
I guess your app is managed by docker-compose as well. There is no need to change which port is MySQL listening in its own container. Leave squelize connecting to databade:3306 and either do not specify port mapping in MySQL docker compose config or specify: 3308:3306 which means that port 3308 on host will be mapped to the 3306 container port. This does not mean that MySQL will listen to the 3308. It will be continuing listening in its container 3306, and a new port 3308 on the host will be mapped to it.
Only specify a port mapping if you need to access MySQL from outside docker-compose services (from another app on your host or a MySQL GUI for example)
In Port section, change second Port to any you want "3308:3309";
Or You can do this in she'll by -p 3309:3308

Connecting SQL running on Vagrant machine through remote host?

I am trying to connect Emma to MySQL running on Vagrant Machine with nginx from a remote location. The server (host) has a static ip that can be accessed through internet. It also has its own running MySQL instance that I can connect to. However I want to connect to Vagrant's MySQL from a remote location.
You will need to expose the port of the MySQL server's running on Vagrant to the public internet. There are a number of ways, but the simplest should be configuring Vagrant with port forwarding.
Since you already have another MySQL server running on the host, you would need to forward on another (free) port than the default, for example 6306:
Vagrant.configure("2") do |config|
config.vm.network "forwarded_port", guest: 3306, host: 6306
end
You would also need to explicitly specify that port in the connection url in Emma.