sudo mysqldump : Permission denied
I am trying to run
sudo mysqldump
with user account but I get : Permission denied
message
If I switch to sudo su
then it works.
The question is why sudo
gives permission denied? should i give some other privileges on my user account?
users privileges
add a comment |
I am trying to run
sudo mysqldump
with user account but I get : Permission denied
message
If I switch to sudo su
then it works.
The question is why sudo
gives permission denied? should i give some other privileges on my user account?
users privileges
The problem is that if i login with root user i can take a mysqldump without problem. But if i login with user account i get permission denied and i must run sudo su first.
– Kapa
Nov 17 '13 at 14:55
add a comment |
I am trying to run
sudo mysqldump
with user account but I get : Permission denied
message
If I switch to sudo su
then it works.
The question is why sudo
gives permission denied? should i give some other privileges on my user account?
users privileges
I am trying to run
sudo mysqldump
with user account but I get : Permission denied
message
If I switch to sudo su
then it works.
The question is why sudo
gives permission denied? should i give some other privileges on my user account?
users privileges
users privileges
edited Nov 17 '13 at 12:52
user164718
asked Nov 17 '13 at 12:08
KapaKapa
21113
21113
The problem is that if i login with root user i can take a mysqldump without problem. But if i login with user account i get permission denied and i must run sudo su first.
– Kapa
Nov 17 '13 at 14:55
add a comment |
The problem is that if i login with root user i can take a mysqldump without problem. But if i login with user account i get permission denied and i must run sudo su first.
– Kapa
Nov 17 '13 at 14:55
The problem is that if i login with root user i can take a mysqldump without problem. But if i login with user account i get permission denied and i must run sudo su first.
– Kapa
Nov 17 '13 at 14:55
The problem is that if i login with root user i can take a mysqldump without problem. But if i login with user account i get permission denied and i must run sudo su first.
– Kapa
Nov 17 '13 at 14:55
add a comment |
6 Answers
6
active
oldest
votes
Try to save dump into user home directory
e.g. mysqldump -u {db_user} -p --databases {db_name} > /home/{user}/my.dump.sql
add a comment |
mysqldump
will need a password for the mysql user root. If you don't supply that password it won't work, sudo
or no sudo.
mysqldump
can look at your .my.cnf
file to get the password, and it'll get that from the user runing the mysqldump
command. So, if the Linux root user has a .my.cnf
configured with a password in it, then yes, sudo will help. However, if the mysql root user has a password and it's not configured in any .my.cnf's then sudo won't help.
You could add the mysql root user and password to your own user's .my.cnf
and then you don't need sudo either, but that's a security risk.
As the other answers point out as well, you might need sudo to write the output somewhere that root (Linux, not mysql) owns.
Lastly, you don't tell us which user is executing the script, if it's in root's crontab (for example), then sudo will not be necessary, although you may still need a .my.cnf
to provide the password.
If your mysql root user has no password set, then the only issue is writing the output, in which case sudo is required if you don't run the script as root.
If you run the script as root (for example, as a script in /etc/cron.daily
) then you should not use sudo within the script, irrespective of all the above
credit
add a comment |
Make sure you command destination path mentioned.
For eg: sudo mysql -u YourUsername -p DatabaseName > ~/Path/Where/you/Want/The/Dump/FiletoBe/Kept/dumpfile.sql
add a comment |
mysqldump requires username of the current user else it will take root as default. When you do aisi su, you automatically provide root access. Try this with your username in place of user. mysqldump -u user -p
Enter password when prompt.
add a comment |
Add write permissions of the folder you want to dump the sql file in:
sudo chmod 755 folder_url
and run:
mysqldump -u user -p db_name > db_dump.sql
add a comment |
mysqldump
on a production server does not work with sudo. Please try this:
$ sudo su
# mysqldump database> database.sql
New contributor
add a comment |
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "89"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f378339%2fsudo-mysqldump-permission-denied%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
6 Answers
6
active
oldest
votes
6 Answers
6
active
oldest
votes
active
oldest
votes
active
oldest
votes
Try to save dump into user home directory
e.g. mysqldump -u {db_user} -p --databases {db_name} > /home/{user}/my.dump.sql
add a comment |
Try to save dump into user home directory
e.g. mysqldump -u {db_user} -p --databases {db_name} > /home/{user}/my.dump.sql
add a comment |
Try to save dump into user home directory
e.g. mysqldump -u {db_user} -p --databases {db_name} > /home/{user}/my.dump.sql
Try to save dump into user home directory
e.g. mysqldump -u {db_user} -p --databases {db_name} > /home/{user}/my.dump.sql
answered Mar 5 '18 at 9:53
Dima KurtashDima Kurtash
212
212
add a comment |
add a comment |
mysqldump
will need a password for the mysql user root. If you don't supply that password it won't work, sudo
or no sudo.
mysqldump
can look at your .my.cnf
file to get the password, and it'll get that from the user runing the mysqldump
command. So, if the Linux root user has a .my.cnf
configured with a password in it, then yes, sudo will help. However, if the mysql root user has a password and it's not configured in any .my.cnf's then sudo won't help.
You could add the mysql root user and password to your own user's .my.cnf
and then you don't need sudo either, but that's a security risk.
As the other answers point out as well, you might need sudo to write the output somewhere that root (Linux, not mysql) owns.
Lastly, you don't tell us which user is executing the script, if it's in root's crontab (for example), then sudo will not be necessary, although you may still need a .my.cnf
to provide the password.
If your mysql root user has no password set, then the only issue is writing the output, in which case sudo is required if you don't run the script as root.
If you run the script as root (for example, as a script in /etc/cron.daily
) then you should not use sudo within the script, irrespective of all the above
credit
add a comment |
mysqldump
will need a password for the mysql user root. If you don't supply that password it won't work, sudo
or no sudo.
mysqldump
can look at your .my.cnf
file to get the password, and it'll get that from the user runing the mysqldump
command. So, if the Linux root user has a .my.cnf
configured with a password in it, then yes, sudo will help. However, if the mysql root user has a password and it's not configured in any .my.cnf's then sudo won't help.
You could add the mysql root user and password to your own user's .my.cnf
and then you don't need sudo either, but that's a security risk.
As the other answers point out as well, you might need sudo to write the output somewhere that root (Linux, not mysql) owns.
Lastly, you don't tell us which user is executing the script, if it's in root's crontab (for example), then sudo will not be necessary, although you may still need a .my.cnf
to provide the password.
If your mysql root user has no password set, then the only issue is writing the output, in which case sudo is required if you don't run the script as root.
If you run the script as root (for example, as a script in /etc/cron.daily
) then you should not use sudo within the script, irrespective of all the above
credit
add a comment |
mysqldump
will need a password for the mysql user root. If you don't supply that password it won't work, sudo
or no sudo.
mysqldump
can look at your .my.cnf
file to get the password, and it'll get that from the user runing the mysqldump
command. So, if the Linux root user has a .my.cnf
configured with a password in it, then yes, sudo will help. However, if the mysql root user has a password and it's not configured in any .my.cnf's then sudo won't help.
You could add the mysql root user and password to your own user's .my.cnf
and then you don't need sudo either, but that's a security risk.
As the other answers point out as well, you might need sudo to write the output somewhere that root (Linux, not mysql) owns.
Lastly, you don't tell us which user is executing the script, if it's in root's crontab (for example), then sudo will not be necessary, although you may still need a .my.cnf
to provide the password.
If your mysql root user has no password set, then the only issue is writing the output, in which case sudo is required if you don't run the script as root.
If you run the script as root (for example, as a script in /etc/cron.daily
) then you should not use sudo within the script, irrespective of all the above
credit
mysqldump
will need a password for the mysql user root. If you don't supply that password it won't work, sudo
or no sudo.
mysqldump
can look at your .my.cnf
file to get the password, and it'll get that from the user runing the mysqldump
command. So, if the Linux root user has a .my.cnf
configured with a password in it, then yes, sudo will help. However, if the mysql root user has a password and it's not configured in any .my.cnf's then sudo won't help.
You could add the mysql root user and password to your own user's .my.cnf
and then you don't need sudo either, but that's a security risk.
As the other answers point out as well, you might need sudo to write the output somewhere that root (Linux, not mysql) owns.
Lastly, you don't tell us which user is executing the script, if it's in root's crontab (for example), then sudo will not be necessary, although you may still need a .my.cnf
to provide the password.
If your mysql root user has no password set, then the only issue is writing the output, in which case sudo is required if you don't run the script as root.
If you run the script as root (for example, as a script in /etc/cron.daily
) then you should not use sudo within the script, irrespective of all the above
credit
answered Nov 17 '13 at 13:47
rɑːdʒɑrɑːdʒɑ
57.9k85218302
57.9k85218302
add a comment |
add a comment |
Make sure you command destination path mentioned.
For eg: sudo mysql -u YourUsername -p DatabaseName > ~/Path/Where/you/Want/The/Dump/FiletoBe/Kept/dumpfile.sql
add a comment |
Make sure you command destination path mentioned.
For eg: sudo mysql -u YourUsername -p DatabaseName > ~/Path/Where/you/Want/The/Dump/FiletoBe/Kept/dumpfile.sql
add a comment |
Make sure you command destination path mentioned.
For eg: sudo mysql -u YourUsername -p DatabaseName > ~/Path/Where/you/Want/The/Dump/FiletoBe/Kept/dumpfile.sql
Make sure you command destination path mentioned.
For eg: sudo mysql -u YourUsername -p DatabaseName > ~/Path/Where/you/Want/The/Dump/FiletoBe/Kept/dumpfile.sql
answered Sep 7 '16 at 20:45
user591987user591987
1
1
add a comment |
add a comment |
mysqldump requires username of the current user else it will take root as default. When you do aisi su, you automatically provide root access. Try this with your username in place of user. mysqldump -u user -p
Enter password when prompt.
add a comment |
mysqldump requires username of the current user else it will take root as default. When you do aisi su, you automatically provide root access. Try this with your username in place of user. mysqldump -u user -p
Enter password when prompt.
add a comment |
mysqldump requires username of the current user else it will take root as default. When you do aisi su, you automatically provide root access. Try this with your username in place of user. mysqldump -u user -p
Enter password when prompt.
mysqldump requires username of the current user else it will take root as default. When you do aisi su, you automatically provide root access. Try this with your username in place of user. mysqldump -u user -p
Enter password when prompt.
answered Mar 5 '17 at 13:30
collinxcollinx
1
1
add a comment |
add a comment |
Add write permissions of the folder you want to dump the sql file in:
sudo chmod 755 folder_url
and run:
mysqldump -u user -p db_name > db_dump.sql
add a comment |
Add write permissions of the folder you want to dump the sql file in:
sudo chmod 755 folder_url
and run:
mysqldump -u user -p db_name > db_dump.sql
add a comment |
Add write permissions of the folder you want to dump the sql file in:
sudo chmod 755 folder_url
and run:
mysqldump -u user -p db_name > db_dump.sql
Add write permissions of the folder you want to dump the sql file in:
sudo chmod 755 folder_url
and run:
mysqldump -u user -p db_name > db_dump.sql
answered Nov 11 '17 at 13:33
WilliamWilliam
1012
1012
add a comment |
add a comment |
mysqldump
on a production server does not work with sudo. Please try this:
$ sudo su
# mysqldump database> database.sql
New contributor
add a comment |
mysqldump
on a production server does not work with sudo. Please try this:
$ sudo su
# mysqldump database> database.sql
New contributor
add a comment |
mysqldump
on a production server does not work with sudo. Please try this:
$ sudo su
# mysqldump database> database.sql
New contributor
mysqldump
on a production server does not work with sudo. Please try this:
$ sudo su
# mysqldump database> database.sql
New contributor
New contributor
answered 2 hours ago
Bryan Zavala ValvidiaBryan Zavala Valvidia
1
1
New contributor
New contributor
add a comment |
add a comment |
Thanks for contributing an answer to Ask Ubuntu!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f378339%2fsudo-mysqldump-permission-denied%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
The problem is that if i login with root user i can take a mysqldump without problem. But if i login with user account i get permission denied and i must run sudo su first.
– Kapa
Nov 17 '13 at 14:55