我没有 Perl 经验。我们正在尝试使用 Perl 脚本将 250MB 数据库移动到 MySQL,该脚本被安排为 Cron 作业 Rackspace 云推荐了这个脚本:
#!/bin/sh mysql -h DB_HOST -u DB_USER -p'DB_PASSWORD' DB_NAME < /path/to/file/db_import.sql
我已经填写了变量(本文的用户和通行证已更改):
!/bin/sh mysql -h mysql51-032.wc1:3306 -u 806637_Admin -p '*******' 806637_Vs_Hl < /mnt/stor09-wc1-ord1/762283/806637/www.vs-hl.com/Vs-hlDB/Vs-DB.sql
做了一些研究,我发现“#”在 Perl 中开始注释,因此我将其删除,这就是我收到的错误报告:
Bareword found where operator expected at main.pl line 1, near "/bin/sh" (Missing operator before h?)
Bareword found where operator expected at main.pl line 1, near "806637_VMHAdmin" (Missing operator before VMHAdmin?)
Number found where operator expected at main.pl line 1, near "'Admin1234' 806637_" (Missing operator before 806637_?)
Bareword found where operator expected at main.pl line 1, near "806637_Vets_Hall" (Missing operator before Vets_Hall?)
syntax error at main.pl line 1, near "/bin/sh mysql "
Execution of main.pl aborted due to compilation errors.
我的问题是我在语法方面做错了什么? 感谢您的阅读!
最佳答案
这不是 Perl 脚本,而是 Bourne Shell 脚本。只需将其移动到两个单独的行即可。
#!/bin/sh
mysql ...
请注意,#!
必须是文件的前两个字符。不能有空行继续。
关于mysql - 在 Rackspace 中移动大型数据库的脚本 - Perl,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24312846/