Ubuntu do I have to specify in the script the password as root?

Hello again all. This time the issue is the script dump the databases.
On Ineta 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.EN/ /home/admin/backup/$DIR/

Taken from here, the link is why it is not displayed.

The script is simple, I like it except for one thing.
In my case, as a user, you need to specify the data root and there is then the question. How safe is it when this script will lie with the root password inside?
Is it possible to create user which will run the script?
March 12th 20 at 07:56
4 answers
March 12th 20 at 07:58
Solution
make a separate user with read only access and do the dump as much as you want. Even limit it to just localhost (since you do it on the same server)
But can be a bit more specific? - Corrine75 commented on March 12th 20 at 08:01
March 12th 20 at 08:00
Solution
create a user backup, run on its behalf. The password will still have to specify.
March 12th 20 at 08:02
Solution
Well, if you're smart enough not to put "on the Internet" your script, why not?
March 12th 20 at 08:04
In Debian (and clones) there is a special MySQL user (debian-sys-maint). For this user there is a special configuration file (/etc/mysql/debian.cnf). You can do dumps, using this file with the option --defaults-file
mysqldump --defaults-file=/etc/mysql/debian.cnf ......
The disadvantage of this solution: run this command only with root privileges for the system.

Find more questions by tags UbuntuMySQL