O'Reilly logo

Linux Shell Scripting Cookbook by Sarath Lakshman

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required