Skip to content

Instantly share code, notes, and snippets.

@sidcoelho
Created August 2, 2019 17:20
Show Gist options
  • Select an option

  • Save sidcoelho/6f662ccd7fd87db31592158738f95be9 to your computer and use it in GitHub Desktop.

Select an option

Save sidcoelho/6f662ccd7fd87db31592158738f95be9 to your computer and use it in GitHub Desktop.
Mysqldump client for DBeaver with Docker (without installing mysql-client)
#!/bin/sh
# File location: /usr/local/bin/mysqldump
# File permission: +x
docker run --rm mysql:latest /usr/bin/mysqldump
@albertopriore
Copy link
Copy Markdown

Hi @sidneydemoraes, I tried this but it's giving me errors like:

Task 'MySQL dump' started at Wed Feb 28 11:30:56 CET 2024
/Users/test/docker-mysqldump/mysqldump: line 5: docker: command not found

Task 'MySQL dump' finished at Wed Feb 28 11:30:56 CET 2024
2024-02-28 11:30:56.258 - IO error: Process failed (exit code = 127). See error log.
2024-02-28 11:30:56.258 - java.io.IOException: Process failed (exit code = 127). See error log.
	at org.jkiss.dbeaver.tasks.nativetool.AbstractNativeToolHandler.validateErrorCode(AbstractNativeToolHandler.java:263)
	at org.jkiss.dbeaver.tasks.nativetool.AbstractNativeToolHandler.executeProcess(AbstractNativeToolHandler.java:241)
	at org.jkiss.dbeaver.tasks.nativetool.AbstractNativeToolHandler.doExecute(AbstractNativeToolHandler.java:283)
	at org.jkiss.dbeaver.ext.mysql.tasks.MySQLNativeToolHandler.doExecute(MySQLNativeToolHandler.java:47)
	at org.jkiss.dbeaver.tasks.nativetool.AbstractNativeToolHandler.lambda$0(AbstractNativeToolHandler.java:87)
	at org.jkiss.dbeaver.runtime.RunnableContextDelegate.lambda$0(RunnableContextDelegate.java:39)
	at org.eclipse.jface.operation.ModalContext$ModalContextThread.run(ModalContext.java:122)

Has it ever happened to you?

@sidcoelho
Copy link
Copy Markdown
Author

/Users/test/docker-mysqldump/mysqldump: line 5: docker: command not found

I assume you do have docker installed, right?
I can see you're running from a HOME path instead of /user/bin.
Check if it's accessible from the path you're running the script.

@albertopriore
Copy link
Copy Markdown

I assume you do have docker installed, right?

Yes I do

I can see you're running from a HOME path instead of /user/bin.
Check if it's accessible from the path you're running the script.

Yes it's accessible, I've attached screenshot running docker --version from /Users/test/docker-mysqldump/
In the attachment there is also the call to mysqldump script with sh mysqldump

Screenshot 2024-03-05 at 14 18 04

Do you have any clue what's happening?

@sidcoelho
Copy link
Copy Markdown
Author

It's weird because the error says line 5: docker: command not found.

Can you try running docker run --rm mysql:latest /usr/bin/mysqldump --version directly?

@albertopriore
Copy link
Copy Markdown

Sure here it is

image

@albertopriore
Copy link
Copy Markdown

@sidneydemoraes did you have a chance to check it out?

@sidcoelho
Copy link
Copy Markdown
Author

sidcoelho commented Mar 22, 2024

@albertopriore I took a look at the error message again and now I think I can see the big picture.
That error log you sent is from DBeaver, right? I noticed that there are Java errors there.
In that case it looks like for some reason DBeaver cannot find docker executable.
Do you run DBeaver as another user?

I'd do this if I were you. Try to run a full mysqldump command straight from commandline. If it works (and looks like it should since you were able to see its version), the problem resides in how you run DBeaver and how the mysqldump script was setup.
It's been a long time I used this solution so TBH I don't remember if I had to do anything special in DBeaver.

@albertopriore
Copy link
Copy Markdown

That error log you sent is from DBeaver, right?

Yes correct.

Do you run DBeaver as another user?

No I don't but could be that as you said the DBeaver cannot find docker executable.

I tried but I'll give up for now, I'll just use another way with a command outside of DBeaver.

Thanks a lot anyway!

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