Writing and reading MySQL database from Bash

MySQL is a widely used Database System. Usually, MySQL databases are used as the storage systems for applications that are written in languages such as PHP, Python, C++, and so on. Accessing and manipulating MySQL databases from shell script will be interesting. We can write scripts to write contents from a text file or CSV (Comma Separated Values) into tables and interact with the MySQL database to read and manipulate data. For example, we can read all the e-mail addresses stored in a guestbook program's database by running a query from the shell script. In this recipe, we will see how to read and write to a MySQL database from Bash. For illustration, here is an example problem:

I have a CSV file containing ...

Get Linux Shell Scripting Cookbook now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.