[Mysql] shell runs mysql SQL statement shell itself is a scripting language, so it cannot connect to the database through APIS Like java. Shell still needs to execute SQL statements by using some running scripts of mysql. It is clear that mysql must be installed on the machine first. You can use the mysql/bin/mysql script to run SQL statements in the format of mysql-hhost-Pport-uusername-ppassword database-e "SQL". The following is the shell code.
[Plain] #! /Bin/sh bin =/usr/local/mysql/bin username = root password = mysql = $ bin/mysql hostname = localhost port = 3306 database = loongdisk table = userio if [" $ password "=" "]; then inputpwd = "" else inputpwd =-p $ password fi # year head = $ database. $ {table} _ month echo $ head SQL = "alter table $ head add column login int (10) unsigned not null default 0 "$ mysql-h $ hostname-P $ port-u $ username $ inputpwd $ database-e" $ SQL"