Linux(Ubuntu)에서 .sh 파일에 저장하지 않도록 SQL 비밀번호가 무엇인지 묻도록 하시겠습니까?

Linux(Ubuntu)에서 .sh 파일에 저장하지 않도록 SQL 비밀번호가 무엇인지 묻도록 하시겠습니까?

내 서버의 문서 루트와 데이터베이스를 즉시 백업하고 이를 내 서버 환경으로 SSH 터널링하는 터미널 시스템에 복사하는 스크립트 파일이 있습니다.

(
cd /var/www/html
zip -r ./html.zip ./
mysqldump -u USER -p PASSWORD --all-databases > ./db.sql
zip backup.zip html.zip db.sql
scp backup.zip /home/user/backups
rm ./html.zip ./db.sql ./backup.zip
)

내 문제:

PASSWORD인 경우 비밀번호를 수동으로 입력해야 합니다. 이것은 제가 이 비밀번호를 마음속에 담아두고 자주 사용하기 때문에 피하고 싶은 것이고, 스크립트 안에 입력하고 싶지 않기 때문입니다.

나의 이상형:

나는 다음 명령(또는 이와 유사한 명령)을 수행할 때마다 암호를 묻는 메시지를 받는 것을 선호합니다.

mysqldump -u USER --all-databases > ./db.sql

내 질문:

Linux 자체를 통해 또는 기존 유틸리티를 통해 이러한 프롬프트를 표시할 수 있습니까?

답변1

mysqldump 맨페이지에서:

 o   --password[=password], -p[password]

           The password to use when connecting to the server. If you use the short option form (-p), you cannot have a space between the option and the password. If you omit the password value following the
           --password or -p option on the command line, mysqldump prompts for one.

           Specifying a password on the command line should be considered insecure. You can use an option file to avoid giving the password on the command line.

-p플래그 에서 비밀번호 값을 생략하면 mysqldump가 비밀번호를 묻는 메시지를 표시합니다.

관련 정보