简体   繁体   中英

How can I copy contents out of MySQL folder without giving ownership of the folder to root in Linux?

I am attempting to back up a MySQL database on a Linux server before I install some upgrades to the software (Omeka) which is using the database.

The command supplied by Omeka documentation for that is the following:

mysqldump -h localhost -u username -p omeka_db_name > omeka_db_backup.sql

However, when I run this, I get the ever so helpfully vague message of "permission denied." It does this if I run the command as sudo. It does this no matter what directory I try to save the backup file to. It doesn't prompt me for a MySQL password when I run mysql dump, but it does when I run "mysql" command and it accepts the password I put in so I know the issue isn't that I'm using the wrong credentials.

I cannot navigate to the MySQL folder directly in shell and when I use WinSCP to access the server, the MySQL folder is listed as owned by "MySQL" and not by "root." So I'm assuming that I don't have permission to copy anything from this folder and that is my problem. I don't want to willy nilly assign ownership of the MySQL folder to root because I'm afraid it might break MySQL's ability to read and write from this folder.

All I want to do is copy the database files somewhere as backup. Heck, I'll copy the whole MySQL folder someplace if I have to do that. How can I do that without breaking MySQL?

Root has permissions for everything. There may be some additional safeguards, depending (there is some security software that limits root permissions). You can just use: mysqldump -h localhost -u username -p omeka_db_name > /path/to/some/other/directory/omeka_db_backup.sql

And put backup in directory you can normally access. If you use the mysqldump you don't need to write to mysql dir.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM