MySQL provides rich operation interfaces for other programming languages. Generally, MySQL can be well managed as long as SQL statements are supported. Shell has limited support for MySQL, and two common direct operations are used.
1) execute the command directly through the "-e" option on the command line.
Format: mysql-uusername-ppassword-e "SQL statement"
Example: mysql-u root-p-e "SELECT Name FROM Country WHERE Name LIKE 'au % '; select count (*) FROM City"
Note: This method can be used when the number of statements is small.
2) SQL statements
Format: mysql-uusername-ppassword <SQL statement 1,
SQL statement 2,
SQL statement 3,
.
.
.
EOF
Note: <example: mysql-uuser-ppwd <EOF
Create database members;
Use members;
Create table admin
(
AdminID int (10) not null AUTO_INCREMENT,
Aname varchar (16) not null,
Aloginame varchar (64) not null,
Aloginpwd varchar (64) not null,
Primary key (adminID)
);
EOF
3) These two methods can be used in a mix in Shell scripts.