출처 :http://ttongfly.net
############################################################################
# Create by NOP_0x90
# E-mail : naneker@hanmail.net
# 프로그램 상에 문제가 있다면 메일 주세요 ^__^
# insert 부분을 자신의 mysql버전의 필드수에 맞게 수정해주세요
############################################################################
#!/bin/bash
if [ $2 ]; then
echo "insert into user values ("localhost","$1",Password("$2"),"N
","N","N","N","N","N","N","N","N","N","N","N","N","N"
,"N","N","N","N","N","N","N","","","","","0","0","0"
);" > /root/.dbadd.sql
echo "insert into db values ("localhost","$1","$1","Y","Y","Y
","Y","Y","Y","Y","Y","Y","Y","Y","Y");" >> /root/.dbadd.sql
echo "create database $1;" >> /root/.dbadd.sql
echo "flush privileges;" >> /root/.dbadd.sql
echo "Mysql password input..."
mysql -u mysql -p mysql < /root/.dbadd.sql
elif [ $1 ]; then
echo "delete from user where User='$1';" > /root/.dbadd.sql
echo "delete from db where Db='$1';" >> /root/.dbadd.sql
echo "drop database $1;" >> /root/.dbadd.sql
echo "flush privileges;" >> /root/.dbadd.sql
echo "Mysql password input..."
mysql -u mysql -p mysql < /root/.dbadd.sql
else
echo "$0 Userid Password"
fi
rm -rf /root/.dbadd.sql
############################################################################
# Create by NOP_0x90
# E-mail : naneker@hanmail.net
# 프로그램 상에 문제가 있다면 메일 주세요 ^__^
# insert 부분을 자신의 mysql버전의 필드수에 맞게 수정해주세요
############################################################################
#!/bin/bash
if [ $2 ]; then
echo "insert into user values ("localhost","$1",Password("$2"),"N
","N","N","N","N","N","N","N","N","N","N","N","N","N"
,"N","N","N","N","N","N","N","","","","","0","0","0"
);" > /root/.dbadd.sql
echo "insert into db values ("localhost","$1","$1","Y","Y","Y
","Y","Y","Y","Y","Y","Y","Y","Y","Y");" >> /root/.dbadd.sql
echo "create database $1;" >> /root/.dbadd.sql
echo "flush privileges;" >> /root/.dbadd.sql
echo "Mysql password input..."
mysql -u mysql -p mysql < /root/.dbadd.sql
elif [ $1 ]; then
echo "delete from user where User='$1';" > /root/.dbadd.sql
echo "delete from db where Db='$1';" >> /root/.dbadd.sql
echo "drop database $1;" >> /root/.dbadd.sql
echo "flush privileges;" >> /root/.dbadd.sql
echo "Mysql password input..."
mysql -u mysql -p mysql < /root/.dbadd.sql
else
echo "$0 Userid Password"
fi
rm -rf /root/.dbadd.sql