首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >‘name 1102 (42000):数据库名不正确

‘name 1102 (42000):数据库名不正确
EN

Stack Overflow用户
提问于 2017-04-07 08:46:23
回答 2查看 4.9K关注 0票数 3

我有一个sh脚本,其内容如下:

代码语言:javascript
复制
#!/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时

代码语言:javascript
复制
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
EN

回答 2

Stack Overflow用户

发布于 2020-04-03 14:10:36

派对有点晚了,但谷歌把我带到了这里。也许能帮上忙。

bash (可能还有其他Linux shell)不喜欢CRLF,请确保使用LF换行保存文件。这对我起了作用。

票数 3
EN

Stack Overflow用户

发布于 2018-03-13 13:09:16

我无法解释发生这种情况的原因,我得到了同样的错误,但我通过在行尾放置密码开关来修复它,如下所示:

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

它对我起了作用

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/43273656

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档