错误 1102 (42000):数据库名称不正确 'database name'

3

我有一个包含以下内容的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
2个回答

3
有点晚了,但是谷歌让我来到这里。也许对某些人有帮助。
bash(可能还包括其他Linux Shell)不喜欢CRLF,请确保将文件以LF换行符保存。这对我很有用。

0

我无法解释为什么会发生这种情况,我遇到了同样的错误,但是我通过将密码开关放在行末来修复它,就像这样:

mysql -r username 'database_name' -p'password'

对我有效。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接