Answer by willg for How to feed mysql queries from bash
cat <<EOD | mysql [-u user] [-ppassword] [database] select 1; select 2; select 3; EOD in your case cat <<EOD | mysql -u root -p CREATE DATABASE IF NOT EXISTS testuser_dev DEFAULT CHARACTER...
View ArticleAnswer by Daniel Pérez Rada for How to feed mysql queries from bash
For big queries in a bash script, you can try: read -d '' SQL_QUERY_1 << EOF SELECT prod.id as id, prod.title as title, comp.name as company, pho.id as photo_id, pho.image as photo_name FROM...
View ArticleAnswer by tim for How to feed mysql queries from bash
The reason your attempt did not work was because the < expects a file name and you fed it a string. You would have to do something like echo "YOURQUERYSTRINGHERE">tmpfile mysql --host=localhost...
View ArticleAnswer by Prince John Wesley for How to feed mysql queries from bash
Try like this: echo "select 1" | mysql
View ArticleAnswer by Ken for How to feed mysql queries from bash
mysql --batch --silent -e 'SHOW TABLES'; Batch and silent are handy if you are planning to pipe the output
View ArticleAnswer by dogbane for How to feed mysql queries from bash
Try using a here document like this: mysql --host=localhost --user=user --password=password << END CREATE USER 'testuser'@'localhost' IDENTIFIED BY 'jakdJxct8W'; CREATE DATABASE IF NOT EXISTS...
View ArticleAnswer by Sorrow for How to feed mysql queries from bash
Have you tried mysql -e query?
View ArticleHow to feed mysql queries from bash
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,...
View Article