Mysqldump launched by cron and password security

后端 未结 6 2140
死守一世寂寞
死守一世寂寞 2020-12-01 04:19

I wrote a script to backup my MySQL databases using:

mysqldump --opt --all-databases -u user -pmypassword > myDump.sql

A cron launches i

6条回答
  •  南笙
    南笙 (楼主)
    2020-12-01 05:05

    Quoting the MySQL docs(http://dev.mysql.com/doc/refman/5.1/en/password-security-user.html):

    Store your password in an option file. For example, on Unix you can list your password in the [client] section of the .my.cnf file in your home directory:

    [client]
    password=your_pass
    

    To keep the password safe, the file should not be accessible to anyone but yourself. To ensure this, set the file access mode to 400 or 600. For example:

    shell> chmod 600 .my.cnf
    

    To name from the command line a specific option file containing the password, use the --defaults-file=file_name option, where file_name is the full path name to the file.

提交回复
热议问题