MySQL Coolify to MySQL Workbench
The below documentation outlines neccessary steps to create a SSH connection between a Coolify MySQL and MySQL Workbench.
Set up Instance
-
Create the MySQL resource within Coolify by selecting the project for the resource. The default 'My first project' is utilized for the document.
-
Select the '+Add New Resource'.
-
Select the desired server for the resource.
-
Once the resource list is presented navigate down the page to the databases section. Select 'New MySQL'.
-
Identify the destination for the resource. Either by selecting a previously built or adding a new destination.
-
SSH into the coolify machine. Run the command
sudo docker run --rm -ti --name=ctop -v /var/run/docker.sock:/var/run/docker.sock quay.io/vektorlab/ctop:latest
. This will list containers running on the machine. Using the arrow keys scroll to the MySQL resource and press enter.The container needs to be in a running state to be accessed
-
The containers listening ports will be listed. This port will be used in the next step.
-
Once the resource is complete, 1) add the desired port to communicate on. In the example port 3000 for the local machine and 3306 for the container. 2) Restart the machine to put the new configs in place.
-
Once restared, check the container to ensure ports are configured appropriately by repeating steps 6&7 above. As an example (below), port 3000 is mapped from the local coolify instance to port 3306 if the mysql container.
Set up Local Host
-
Set up SSH tunnel on your local machine that is running the MySQL client (ie. mysql or MySQL Workbench) by running the below command.
ssh -4 -f -N -T -L 3131:127.0.0.1:3000 cloud@coolify_public_ip_here
-
Open MySQL Workbench and select '+' toggle to add a new connection.
-
In the pop up add a name for the connection. Make hostname localhost 127.0.0.1 and port 3131 as set previously. Select test connection.
-
Provide the MySQL root password from coolify in the MySQL Workbench pop up. Optionally, save the password to keychain for quick launch.
-
Select the newly built connection. If prompted provide root password.
-
Select 'Server Status' from the left navigation menu.
-
Ensure connection and server is running.
MySQL Workbench is now connected to the Coolify MySQL resource and editable.