如何从饲料的bash MySQL的查询 [英] How to feed mysql queries from bash
本文介绍了如何从饲料的bash MySQL的查询的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我试图使创建MySQL用户和数据库bash脚本,但我不能找到一种方法来养活SQL到mysql,我想用这种格式:
I'm trying to make a bash script that creates a mysql user and database but I can't find a way to feed the sql into mysql, I'm trying with this format:
mysql < echo "query"
但不工作,请参见下面的例子:
But that is not working, see the example below:
mysql --host=localhost --user=user --password=password < echo "CREATE USER 'testuser'@'localhost' IDENTIFIED BY 'jakdJxct8W';
CREATE DATABASE IF NOT EXISTS 'testuser_dev' DEFAULT CHARACTER SET utf8 COLLATE utf8_bin;
GRANT ALL PRIVILEGES ON 'testuser_dev' . * TO 'testuser'@'localhost';
CREATE DATABASE IF NOT EXISTS 'testuser_qa' DEFAULT CHARACTER SET utf8 COLLATE utf8_bin;
GRANT ALL PRIVILEGES ON 'testuser_qa' . * TO 'testuser'@'localhost';"
如何使用查询喂MySQL的?
How to feed mysql with the queries?
推荐答案
尝试这样的:
echo "select 1" | mysql
这篇关于如何从饲料的bash MySQL的查询的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文