Q
Q
Qq2018-10-09 12:21:04
MySQL
Qq, 2018-10-09 12:21:04

Ubuntu, should I specify the root password in the script?

Hello again everyone. This time the question is about the database dump script.
On the Internet, I found a simple script

DIR=`date +%F_%H-%M`;
mkdir /home/backup/$DIR;
mysqldump -uroot -p12345 my_girl_db > /home/admin/backup/my_girl_db.sql
zip -r -0 /home/www/you_site.ru/ /home/admin/backup/$DIR/

Taken from here, for some reason the link is not displayed.
The script is simple, everything suits me except for one moment.
In my case, you need to specify root data as a user and the question immediately arises. How safe is it when this script will lie with the root password inside?
Is it possible to create a user from which this script will run?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
I
Ivan Shumov, 2018-10-09
@qq

make a separate read-only user and dump to your heart's content. Limit it to only localhost yet (since you're doing it on the same server)

A
AVKor, 2018-10-09
@AVKor

Debian (and clones) has a special MySQL user (debian-sys-maint). There is a special configuration file for this user (/etc/mysql/debian.cnf). Dumps can be made using this file with the option --defaults-file
mysqldump --defaults-file=/etc/mysql/debian.cnf ...... The
downside of this solution is that you can only run this command as a system root.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question