I don't quite understand how to extract all the datum from the MySQL my_database
database by using BASH. Ideally I would like to extract the data line by line, and print it out into mydata.csv
text file line by line [with an IFS].
My difficulty is how to read the lines individually, and have each of the columns separated with an infield separator "," .
I became even more perplexed after do some reading:
- http://www.garron.me/en/bits/mysql-select-multiple-conditions.html
- bash script - select from database into variable
- https://www.pantz.org/software/mysql/mysqlcommands.html
Any help is much appreciated!
I've thus far implemented
#!/bin/bash
myvariable=$(echo "SELECT * FROM cs_microrage_crm.stock_trans" | mysql -uUSER -pPASSWORD)
echo $myvariable
This results to ERROR 1045 (28000):