添加快启动即命令行
~$ vi .bash_aliases
alias mysqlxdb='mysql -uroot -p1 xdb'
~$ source .bashrc 创建脚本xdb.sh#! /bin/shexec mysql -uroot -p1 xdb 赋予执行权限$chmod +x xdb.sh$xdb.sh 或者 $ ./xdb.sh 批处理 按照mysql格式整齐输出结果并写入tm1. $ mysql -t -uroot -p1 xdb < mysql/t.sql > tm 2. 编写脚本xdb2.sh#! /bin/shif [ $# -ne 1 ]; then echo 'Please input the search words'; exit; fi#exec mysql -uroot -p1 xdbmysql -t -uroot -p1 xdb <<QUERY_INPUTselect * from memberwhere province like '%$1%'order by lastname;QUERY_INPUT $ ./xdb.sh 西 $ ./xdb.sh '西' +----+----------+-----------+--------+------------+-------+-----+------------+-----------+| id | lastname | firstname | status | birthday | score | sex | datenow | province |+----+----------+-----------+--------+------------+-------+-----+------------+-----------+| 7 | g | g | s | 1973-09-06 | 60 | 0 | 2015-11-08 | 山西省 || 3 | hacker | johner | s | 1925-03-06 | 100 | 0 | 2015-11-08 | 江西省 || 8 | y | y | s | 1983-01-06 | 60 | 0 | 2015-11-08 | 陕西省 |+----+----------+-----------+--------+------------+-------+-----+------------+-----------+