【发布时间】:2018-07-01 06:53:55
【问题描述】:
我正在运行我创建的用于下载和安装 WordPress 的脚本。为了节省更多时间,我想打开 MAMP MYSQL 并创建一个新数据库,如下所示:
/Applications/MAMP/Library/bin/mysql --host=localhost -uroot -proot
CREATE DATABASE $1; // passed into the function as argument
exit; // to get out of MYSQL
我的其余功能:
wordpress() {
cd /Volumes/example/example/Web/dev; mkdir $1;
cd $1;
curl -O https://wordpress.org/latest.tar.gz;
tar -xvzf latest.tar.gz;
mv wordpress/* .;
rmdir wordpress/;
rm latest.tar.gz;
cp wp-config-sample.php wp-config.php;
vim -s /Volumes/example/example/Web/dev/db_overwrite.txt wp-config.php;
curl -O https://downloads.wordpress.org/plugin/wp-super-cache.latest-stable.zip;
curl -O https://downloads.wordpress.org/plugin/wp-migrate-db.latest-stable.zip;
curl -O https://downloads.wordpress.org/plugin/contact-form-7.latest-stable.zip;
curl -O https://downloads.wordpress.org/plugin/wordpress-seo.latest-stable.zip
mv wp-super-cache.latest-stable.zip wp-migrate-db.latest-stable.zip contact-form-7.latest-stable.zip wordpress-seo.latest-stable.zip wp-content/plugins;
cd wp-content/plugins;
cp /Volumes/example/example/Web/Plugins/advanced-custom-fields-pro.zip .
unzip advanced-custom-fields-pro.zip;
unzip wp-super-cache.latest-stable.zip;
unzip wp-migrate-db.latest-stable.zip;
unzip contact-form-7.latest-stable.zip;
unzip wordpress-seo.latest-stable.zip;
rm wp-super-cache.latest-stable.zip wp-migrate-db.latest-stable.zip contact-form-7.latest-stable.zip wordpress-seo.latest-stable.zip;
cd ../themes;
git clone https://github.com/example/my-template;
}
如何将 MYSQL 行添加到此函数并使其按预期工作?
谢谢
【问题讨论】:
-
如果您使用的是 Linux,请阅读以下内容:shellhacks.com/mysql-run-query-bash-script-linux-command-line
-
@Roadowl 这些很有帮助,但我也想通过传递给函数的参数动态创建数据库名称,如下所示:wordpress my_wordpress
标签: mysql wordpress shell terminal