Skip to content

Instantly share code, notes, and snippets.

@kekeimiku
Last active January 18, 2024 15:36
Show Gist options
  • Save kekeimiku/e1da488d96727789de88332499a51d57 to your computer and use it in GitHub Desktop.
Save kekeimiku/e1da488d96727789de88332499a51d57 to your computer and use it in GitHub Desktop.
Dbeaver connect to docker database unable to export and import temporary solutions. mysql/postgres
#!/bin/sh
docker exec -i mysql /usr/bin/mysql $@ -p2325373912
#!/bin/sh
docker exec -i mysql /usr/bin/mysqldump $@ -p2325373912
#!/bin/sh
docker exec -i postgres /usr/local/bin/pg_dump $@
#!/bin/sh
docker exec -i postgres /usr/local/bin/pg_restore $@
@kekeimiku
Copy link
Author

localclient set to the directory where the above file is located

@ssheduardo
Copy link

I have created mysqldump in /usr/local/bin
Now when I want to export the database I get an error.
The database is in my container and I access it with ip 0.0.0.0.0 and port 3307.

image

@dmcallejo
Copy link

@ssheduardo Assuming your container has the port 3307 exposed to your local machine, use the loopback IP address of your computer to access the container, 127.0.0.1 and port 3307

Same goes to the OP: if you use the host "localhost" the mysql client will use the socket connection to connect to the database for some unknown reason. Use the loopback address whenever you want to connect to the database from outside using the mysql client.

@acasaism
Copy link

@ssheduardo Assuming your container has the port 3307 exposed to your local machine, use the loopback IP address of your computer to access the container, 127.0.0.1 and port 3307

Same goes to the OP: if you use the host "localhost" the mysql client will use the socket connection to connect to the database for some unknown reason. Use the loopback address whenever you want to connect to the database from outside using the mysql client.

Thanks!!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment