Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/shell/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Mysql ';错误1102(42000):数据库名称不正确';数据库名称_Mysql_Shell_Ubuntu - Fatal编程技术网

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

Mysql ';错误1102(42000):数据库名称不正确';数据库名称,mysql,shell,ubuntu,Mysql,Shell,Ubuntu,我有一个包含以下内容的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 |

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


我无法解释为什么会发生这种情况,我得到了相同的错误,但我通过将密码开关放在行的末尾来修复它,如下所示:

mysql-r用户名'database\u name'-p'password'


这对我来说很管用,虽然我参加聚会晚了一点,但谷歌把我带到了这里。也许它会帮助别人

bash(可能还有其他Linux shell)不喜欢CRLF,请确保使用LF换行符保存文件。这对我来说是个好办法

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