您的位置:首页 > 运维架构 > Shell

简单数据库及表创建shell脚本

2012-09-10 21:03 246 查看
[python] view plaincopyprint?
#!/bin/bash

USER='root'
PASS='123'

mysql -u $USER -p$PASS <<EOF 2> /dev/null
create database test1;
EOF

[ $? -eq 0 ] && echo "The database Created test1" || echo "The database test1 is already exist"

mysql -u $USE test1 <<EOF 2> /dev/null
create table test1(
ind int,
name varchar(20)
);
EOF

[ $? -eq 0 ] && echo "The table Created test1" || echo "The table test1 is already exist"

mysql -u $USER -p$PASS test1 <<EOF
DELETE FROM test1;
EOF
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: