sudo mysqldump : Permission deniedHow to create a user with root privileges in bash?Problem accessing superuser with sudoTemporary Admin Status for System Maintenance on User AccountHow does the sudoers work?How can I get an interactive shell as another non-root user?Admin to root privilegesLooking for a better solution to execute a single sudo command when using a normal user account?Run sudo commands from standard accountPermission denied please try again ssh error
How often are there lunar eclipses on Jupiter
How can I run a realistic open-world game with vast power differences, without resulting in constant TPKs?
Puzzling is a Forte of Mine
Regulation for ETFs in the UK after the Brexit
What is the difference between "cat < filename" and "cat filename"?
Why can't sonic booms be heard at air shows?
How to upgrade SSD from HDD for my mac book pro
Are monosubstituted cyclopropanes achiral or chiral?
Old story about a man with tattoos that told stories
My professor changed a take-home test to an in-class test with no notice. Can I fight the grade?
Cheap and safe way to dim 100+ 60W Incandescent bulbs
Why didn't Philippine Airlines Flight 113 dump fuel prior to forced landing?
How can I offer my prayers to an atheist colleague facing a serious personal situation?
Journal editor made bad edits to my (accepted) paper - how do I respond?
Why is the Toffoli gate not sufficient for universal quantum computation?
How does "unlimited holidays" work in practice?
How can I justify this without determining the determinant?
How to differentiate landing on top of an object from falling down the side?
Short story about delivery truck organization existing only to support itself
Unstable manifolds of a Morse function give a CW complex
Pre-2000s novel about tourism through time travel
Plane ticket price went down by 40% two weeks after I booked it. Is there anything I can do to get a refund?
What is the rationale for single engine military aircraft?
Can the diameter be controled by the injectivity radius and the volume?
sudo mysqldump : Permission denied
How to create a user with root privileges in bash?Problem accessing superuser with sudoTemporary Admin Status for System Maintenance on User AccountHow does the sudoers work?How can I get an interactive shell as another non-root user?Admin to root privilegesLooking for a better solution to execute a single sudo command when using a normal user account?Run sudo commands from standard accountPermission denied please try again ssh error
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty
margin-bottom:0;
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
That is because even though sudo gives you elevated privileges it doesn't change the user that you are trying to access the db with. Meaning if you are trying it with sudo mysqldump it is still trying it with your user but with elevated permissions, but with sudo su you become root - a user which exists in the DB by default - which makes it work.
– Ziazis
Sep 19 at 7:07
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
511 gold badge1 silver badge3 bronze badges
511 gold badge1 silver badge3 bronze badges
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
That is because even though sudo gives you elevated privileges it doesn't change the user that you are trying to access the db with. Meaning if you are trying it with sudo mysqldump it is still trying it with your user but with elevated permissions, but with sudo su you become root - a user which exists in the DB by default - which makes it work.
– Ziazis
Sep 19 at 7:07
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
That is because even though sudo gives you elevated privileges it doesn't change the user that you are trying to access the db with. Meaning if you are trying it with sudo mysqldump it is still trying it with your user but with elevated permissions, but with sudo su you become root - a user which exists in the DB by default - which makes it work.
– Ziazis
Sep 19 at 7:07
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
That is because even though sudo gives you elevated privileges it doesn't change the user that you are trying to access the db with. Meaning if you are trying it with sudo mysqldump it is still trying it with your user but with elevated permissions, but with sudo su you become root - a user which exists in the DB by default - which makes it work.
– Ziazis
Sep 19 at 7:07
That is because even though sudo gives you elevated privileges it doesn't change the user that you are trying to access the db with. Meaning if you are trying it with sudo mysqldump it is still trying it with your user but with elevated permissions, but with sudo su you become root - a user which exists in the DB by default - which makes it work.
– Ziazis
Sep 19 at 7:07
add a comment
|
7 Answers
7
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
on a production server does not work with sudo. Please try this:
$ sudo su
# mysqldump database> database.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
|
This did work for me:
mysqldump -u db_user -p --databases db_name > /home/$USER/my.dump.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
|
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
|
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/4.0/"u003ecc by-sa 4.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
7 Answers
7
active
oldest
votes
7 Answers
7
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
312 bronze badges
312 bronze badges
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
add a comment
|
mysqldump
on a production server does not work with sudo. Please try this:
$ sudo su
# mysqldump database> database.sql
add a comment
|
mysqldump
on a production server does not work with sudo. Please try this:
$ sudo su
# mysqldump database> database.sql
mysqldump
on a production server does not work with sudo. Please try this:
$ sudo su
# mysqldump database> database.sql
answered Feb 20 at 3:31
Bryan Zavala ValvidiaBryan Zavala Valvidia
311 bronze badge
311 bronze badge
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ʒɑ
80.1k88 gold badges224 silver badges309 bronze badges
80.1k88 gold badges224 silver badges309 bronze badges
add a comment
|
add a comment
|
This did work for me:
mysqldump -u db_user -p --databases db_name > /home/$USER/my.dump.sql
add a comment
|
This did work for me:
mysqldump -u db_user -p --databases db_name > /home/$USER/my.dump.sql
add a comment
|
This did work for me:
mysqldump -u db_user -p --databases db_name > /home/$USER/my.dump.sql
This did work for me:
mysqldump -u db_user -p --databases db_name > /home/$USER/my.dump.sql
edited Sep 18 at 23:42
Pablo A
4,5953 gold badges23 silver badges50 bronze badges
4,5953 gold badges23 silver badges50 bronze badges
answered Sep 18 at 17:13
Pish PeterPish Peter
111 bronze badge
111 bronze badge
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 bronze badges
1012 bronze badges
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
That is because even though sudo gives you elevated privileges it doesn't change the user that you are trying to access the db with. Meaning if you are trying it with sudo mysqldump it is still trying it with your user but with elevated permissions, but with sudo su you become root - a user which exists in the DB by default - which makes it work.
– Ziazis
Sep 19 at 7:07