Quantcast
Channel: How to feed mysql queries from bash - Stack Overflow
Browsing latest articles
Browse All 8 View Live

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 Article



Answer 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 Article

Answer 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 Article

Answer by Prince John Wesley for How to feed mysql queries from bash

Try like this: echo "select 1" | mysql

View Article

Answer 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 Article


Answer 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 Article

Answer by Sorrow for How to feed mysql queries from bash

Have you tried mysql -e query?

View Article

How 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

Browsing latest articles
Browse All 8 View Live




Latest Images