[英]Empty MySQL database and import from bash script?
Im trying to empty a database and import into it from a bash script. 我试图清空数据库并从bash脚本导入数据库。 Im using MySQL from Mamp Pro. 我正在使用Mamp Pro中的MySQL。 The following logs me into MySQL but doenst run any of the operations. 以下内容将我登录到MySQL,但不会运行任何操作。
/applications/MAMP/library/bin/mysql -u root -p
DROP DATABASE database_name;
CREATE DATABASE database_namem;
database_name < /file-to-import.sql;
I think you're suppose to execute the query as a string like this: 我认为您假设要像这样的字符串执行查询:
/applications/MAMP/library/bin/mysql -u root -pYourPassword -e "DROP DATABASE database_name;"
It might be possible to execute multiple queries this way by separating with ;
通过用;
分隔,可以执行这种查询;
but I have not tried. 但是我没有尝试过。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.