Shell to operate mysql database mysql-hhostname-Pport-uusername-ppassword-e related mysql SQL statements, you can operate mysql in shell without running mysql at a mysql prompt. #! /Bin/bash HOSTNAME = "192.168.111.84"; # Database Information PORT = "3306"; USERNAME = "root"; PASSWORD = ""; DBNAME = "test_db_test "; # Database Name TABLENAME = "test_table_test "; # Name of the table in the database # create database create_db_ SQL = "create database IF NOT EXISTS $ {DBNAME}" mysql-h $ {HOSTNAME}-P $ {PORT}-u $ {USERNAME} -p $ {PASSWORD}-e "$ {create_db_ SQL}" # create a table create_table_ SQL = "create table IF NOT EXISTS $ {TABLENAME} (namevarchar (20 ), id int (11) default 0) "mysql-h $ {HOSTNAME}-P $ {PORT}-u $ {USERNAME}-p $ {PASSWORD }$ {DBNAME}-e" $ {create_table_ SQL} "# insert data insert_ SQL = "insertinto $ {TABLENAME} values ('billchen ', 2) "mysql-h $ {HOSTNAME}-P $ {PORT}-u $ {USERNAME}-p $ {PASSWORD }$ {DBNAME}-e" $ {insert_ SQL} "# Query select_ SQL = "select * from $ {TABLENAME}" mysql-h $ {HOSTNAME}-P $ {PORT}-u $ {USERNAME}-p $ {PASSWORD} $ {DBNAME} -e "$ {select_ SQL}" # update data update_ SQL = "update $ {TABLENAME} set id = 3" mysql-h $ {HOSTNAME}-P $ {PORT}-u $ {USERNAME}-p $ {PASSWORD }$ {DBNAME}-e "$ {update_ SQL}" mysql-h $ {HOSTNAME}-P $ {PORT}-u $ {USERNAME} -p $ {PASSWORD }$ {DBNAME}-e "$ {select_ SQL}" # e_ SQL = "deletefrom $ {TABLENAME}" mysql-h $ {HOSTNAME}-P $ {PORT}-u $ {USERNAME}-p $ {PASSWORD }$ {DBNAME}-e "$ {delete_ SQL}" mysql-h $ {HOSTNAME}-P $ {PORT} -u $ {USERNAME}-p $ {PASSWORD }$ {DBNAME}-e "$ {select_ SQL }"