我有一个sh脚本,其内容如下:
#!/bin/sh
mysqldump -hmy.host.com --user=p387829 --password=pwd --
all-databases > /backup/mysqlall-`/bin/date +\%Y\%m\%d\%h\%i\%s`.sql
mysqldump -u p387829 -hmy.host.com --password=pwd --add-
drop-table --no-data usr_p387829_1 | grep ^DROP | mysql -up387829 -
pPwd -hmy.host.com usr_p387829_1
mysqldump -u p387829 -hmy.host.com --password=pwd
usr_p387829_2 | mysql -u p387829 -pPwd -hmy.host.com
usr_p387829_1当我在shell中单独执行每个命令时,它可以工作。但是当我执行sh script.sh时
Warning: Using a password on the command line interface can be insecure.
Warning: Using a password on the command line interface can be insecure.
Warning: Using a password on the command line interface can be insecure.
'RROR 1102 (42000): Incorrect database name 'usr_p387829_1
Warning: Using a password on the command line interface can be insecure.
Warning: Using a password on the command line interface can be insecure.
'RROR 1102 (42000): Incorrect database name 'usr_p387829_1
mysqldump: Got errno 32 on write发布于 2020-04-03 14:10:36
派对有点晚了,但谷歌把我带到了这里。也许能帮上忙。
bash (可能还有其他Linux shell)不喜欢CRLF,请确保使用LF换行保存文件。这对我起了作用。
发布于 2018-03-13 13:09:16
我无法解释发生这种情况的原因,我得到了同样的错误,但我通过在行尾放置密码开关来修复它,如下所示:
mysql -r username 'database_name' -p'password'
它对我起了作用
https://stackoverflow.com/questions/43273656
复制相似问题