示例脚本(感谢Bill Karwin为–user和–password注释!):
原文链接:/bash/386846.html#!/bin/bash ## --user=XXXXXX --password=XXXXXX *may* not be necessary if run as root or you have unsecured DBs but ## using them makes this script a lot more portable. Thanks @billkarwin RESULT=`MysqLshow --user=XXXXXX --password=XXXXXX myDatabase| grep -v Wildcard | grep -o myDatabase` if [ "$RESULT" == "myDatabase" ]; then echo YES fi
这些是在提示符下运行时的命令:
[root@host ~]# MysqLshow myDatabase Wildcard: myDatabase +------------------+ | Databases | +------------------+ | myDatabase | +------------------+
如果没有DB,输出将如下所示:
[root@host ~]# MysqLshow myDatabase Wildcard: myDatabase +-----------+ | Databases | +-----------+ +-----------+