Bash script that connects to a mysql DB to dump column value. It performs this in batches instead of one try. Useful when exporting large amount of data.
|# Connects to a MySQL database to dump data in batches.|
|# Great for dumping large datasets.|
|# This loops until it has read MAX_ROWS|
|while [ $OFFSET -lt $MAX_ROWS ]|
|echo "Fetching rows starting $OFFSET"|
|echo "SELECT COL_NAME FROM TABLE_NAME LIMIT $LIMIT OFFSET $OFFSET" | mysql DATABASE_NAME --skip-column-names -B -u MYSQLUSERNAME -pMYSQL_PASSWD >> output.csv|
|# All you have to do is tweak the LIMIT and MAX variable to your liking.|