Skip to Content
Mastering Linux Shell Scripting - Second Edition
book

Mastering Linux Shell Scripting - Second Edition

by Mokhtar Ebrahim, Andrew Mallett
April 2018
Beginner
284 pages
7h 3m
English
Packt Publishing
Content preview from Mastering Linux Shell Scripting - Second Edition

Version 3 – MySQL/MariaDB

In the next script, we will provide the detail for a database connection along with the SQL query to execute. You will be able to run this if you have a MariaDB or MySQL database server on your system, or one that you can connect to. For this demonstration, we will use Linux Mint 18.3 and MariaDB version 10; however, this should work for any MySQL server or MariaDB, from version 5 onwards. The script collects user and password information as well as the SQL command to execute. Create the following script as $HOME/bin/run_mysql.sh:

#!/bin/bash# Author: @theurbanpenguin# Web: www.theurbapenguin.com# Script to prompt for MYSQL user password and command# Last Edited: July 4 2015read -p "MySQL User: " user_nameread -sp ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Learning Linux Shell Scripting - Second Edition

Learning Linux Shell Scripting - Second Edition

Ganesh Sanjiv Naik
Linux Shell Scripting Cookbook - Third Edition

Linux Shell Scripting Cookbook - Third Edition

Clif Flynt, Sarath Lakshman, Shantanu Tushar

Publisher Resources

ISBN: 9781788990554Supplemental Content