i have to make backups of mysql database in my application.
I run the command in Windows and works nice. This is the command:
String executeCmd = mysqldumppath +" -u " + dbUserName + " -p" + dbPassword + " --add-drop-database -B " + dbName + " -r " + filePath;
Runtime.getRuntime().exec(executeCmd);
When i try this command on my linux server, i need to put a sudo password. How i pass password in the command line?
I had read many solutions but no success.
Why are you have to enter password when execute the mysqldump command use the glassfish user?
Because you just have the privilege that execute the command with a password. If you want to execute commands
password-less
, edit the/etc/sudoers
file use visudo, put a line in the end(if you run the glassfish server useglassfish
user), eg:You can also copy the line into a file and put it to the /etc/sudoers.d directory. Now, try execute the command use sudo again! Good luck! :-)