%EC%97%90%EC%84%9C%20SQL%20%EB%B9%84%EB%B0%80%EB%B2%88%ED%98%B8%EA%B0%80%20%EB%AC%B4%EC%97%87%EC%9D%B8%EC%A7%80%20%EB%AC%BC%EC%96%B4%EB%B3%B4%EA%B2%8C%20%ED%95%98%EC%97%AC%20.sh%20%ED%8C%8C%EC%9D%BC%EC%97%90%20%EC%A0%80%EC%9E%A5%ED%95%98%EC%A7%80%20%EC%95%8A%EB%8F%84%EB%A1%9D%20%ED%95%98%EC%8B%9C%EA%B2%A0%EC%8A%B5%EB%8B%88%EA%B9%8C%3F.png)
서버의 문서 루트와 데이터베이스를 즉시 백업하고 이를 내 서버 환경으로 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
)
내 질문:
"비밀번호"에 비밀번호를 수동으로 입력해야 합니다. 이 비밀번호는 머리 속에 내면화해서 자주 사용하고, 스크립트에 입력하고 싶지 않기 때문에 피하고 싶은 것입니다.
나의 이상형:
다음 명령(또는 이와 유사한 명령)을 실행할 때마다 암호를 묻는 메시지가 표시되기를 원합니다.
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가 비밀번호를 묻는 메시지를 표시합니다.