Creating a table in MySQL

We have successfully created a database named testdb and a user named user1, and have also granted all of the privileges on the testdb database.

Now we will create a table. Create the script to list the table:

mysql -u user1 -pTest623@!   <<MY_QUERY 
use testdb; 
show tables; 

Now save the program and run it as follows:

          $ chmod +x
          $ ./

The preceding command will not show presence of any table, as we only just have created our database.

Now, we are going to create a table named Authors. Create the script to create a table named Authors:

#!/bin/bash mysql -u user1 -pTest623@! <<MY_QUERY use testdb; CREATE TABLE Authors(Id INT PRIMARY KEY AUTO_INCREMENT, ...

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

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