Stupid Question re: Mariadb backup with mysqldump

Hello all,

I’m sorry for the stupid question, but I am a new Linux user and there is a great deal to learn.

I have been following the Nextcloud backup procedure https://docs.nextcloud.com/server/stable/admin_manual/maintenance/backup.html but would like to clarify the mysqldump backup process.

I’m wondering what is the consensus for using the root - mysql user, for dumping the Nextcloud database, I’ve read some posts of users stating it is a bad idea to use root?

Any clarification would be appreciated.

If you don’t need the permissions, it is better to use a user with limited access. So you wouldn’t run Nextcloud with root permissions. However, for the backup, as root, you can backup the all databases, not just the Nextcloud-db.

1 Like

I have been using the mysql root user just for backing up/dumping the NC database, however that database has it’s own mysql user which Nextcloud uses for its operation.

I currently run an rsync backup on the entire server to backup/snapshot the entire system, as well as an additional backup following the Nextcloud admin manual recommendations (data folder, NC folder & NC SQL database).

As I have to run the backup’s manually (I use an encrypted external drive to store backups) I have to manually enter the mysql root password everytime. After reading a few posts I thought I may be in error using the root sql user.

Thanks for the clarification, it is much appreciated :+1:

Perhaps you can use this tuturial .
Also it is possible to set password in my.cnf . Search the internet.

depending on your distro mysql/mariadb may be preconfigured for root (locally) w/out password at all (eg debian.) if you execute the command mysql as root you are not required to supply the password and there is no .my.cnf with password either in this case.
you can also run mysqldump -u <USER> -p <PASS> .... inside your script if you consider this safe enough.
i usually run mysqldump as root since (a long time ago) i ran into some privilege problems with the db-users and also i backup all dbs at the same time.
GOOD LUCK!

1 Like

I have noticed that I can log into MariaDB/mysql from root without the password (Ubuntu 20.04LTS).
I’ve been waiting until I feel more comfortable with Linux before I configure automated backups (I plan to use crontab).
You input has given me confidence that I am heading in the right direction, I really appreciate the input :+1:t3: