Creating a database

In this section, you will learn about a creating new database in MySQL. We are going to use this database throughout this chapter. Create the script mysql_02.sh to create the database:

#!/bin/bash 
mysql -u root -pTraining2@^ <<MY_QUERY 
create database testdb; 
MY_QUERY 

Now save the program and run it as follows:

 $ chmod +x mysql_02.sh $ ./mysql_02.sh

Get Learning Linux Shell Scripting - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.