Version 0.1
<< mysql user ¹× db °ü¸® Åø >>
ÀÛ¼º Shell ÇÁ·Î±×·¡¹Ö
ÀÛ¼ºÀÚ stone
<<Ư¡
DB¸¦ »ý¼ºÇÏ¿© ±×DB¸¸ Çڵ鸵 ÇÒ¼öÀÖµµ·Ï USERÀÇ ±ÇÇÑÀ»
Á¶Á¤ÇßÀ¸¸ç ÇöÀç µî·ÏµÈ USER ¹× DB ¸®½ºÆ®Á¶È¸¹×
»èÁ¦°¡´ÉÇÏ´Ù.
>>
<<»ç¿ë¹ý>>
mysqlpass º¯¼ö¿¡ mysqlÀÇ ½ÇÇàÈÀÏ °æ·Î¸¦ Àû¾îÁØ´Ù.
µðÆúÆ®´Â /usr/local/mysql/bin/mysql·Î µÇ¾îÀÖÀ½.
¾Æ·¡ÀÇ ³»¿ëÀ»
mysqluser.sh ÆÄÀÏ(Çʼö) ·Î ÀúÀåÇÑÈÄ
chmod +x mysqluser.sh
%mysqluser <--enter
clear
mysqlpass="/usr/local/mysql/bin/mysql"
if [ -s mysqltmp ]
then
rm mysqltmp
fi
echo "============================================================="
echo " MYSQL USER MANAGER "
echo "============================================================="
echo " 1. USER CREATE AND DB CREATE "
echo " 2. DROP USER AND DB DROP "
echo " 3. View USER "
echo " 4. View DATABASE "
echo " 5. EXIT "
echo " ¡Ø. EXECUTE,AFTER CONFIRM MYSQL ROOT' PASSWORD "
echo "============================================================="
echo "ÀÛ¾÷À» ¼±ÅÃÇϼ¼¿ä>>\c"
read job
case $job in
"") echo "°ªÀ» ÀÔ·ÂÇϼ¼¿ä"
mysqluser.sh;;
"1")
echo "user »ý¼º dbÀÔ·Â:\c"
read db
echo "mysql userÀÔ·Â:\c"
read user
echo "user passwdÀÔ·Â:\c"
read pass
echo "=============================================================\n"
echo "create database $db;" >> mysqltmp
echo "insert into user values ('localhost','$user',password'$pass'),'N','N','N','N','N','N','N','N','N','N','N','N','N','N');">>mysqltmp
echo "insert into db values('localhost','$db','$user','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y');" >>mysqltmp
echo "flush privileges;">>mysqltmp
$mysqlpass -uroot -p mysql <mysqltmp
rm mysqltmp
mysqluser.sh
;;
"2")
echo "»èÁ¦ user dbÀÔ·Â:\c"
read db
echo "»èÁ¦ userÀÔ·Â:\c"
read user
echo "delete from user where user='$user';" >>mysqltmp
echo "delete from db where user='$user';" >>mysqltmp
echo "user db¸¦ ¿µ±¸ÀûÀ¸·Î »èÁ¦ ÇÒ±î¿ä[y,n]\c";
read yn
if [ $yn = "y" ]
then
echo "drop database $db;" >>mysqltmp
echo "flush privileges;" >>mysqltmp
fi
$mysqlpass -uroot -p mysql <mysqltmp
rm mysqltmp
mysqluser.sh
;;
"3")
clear
echo "============================================================="
echo " VIEW USER "
echo "============================================================="
echo "select user from user;">>mysqltmp
$mysqlpass -uroot -p mysql <mysqltmp
rm mysqltmp
echo "============================================================="
echo "Press Any key.......................\c"
read dumy
mysqluser.sh
;;
"4")
clear
echo "============================================================="
echo " VIEW DATABASE,USER "
echo "============================================================="
echo "select db,user from db;">>mysqltmp
$mysqlpass -uroot -p mysql <mysqltmp
rm mysqltmp
echo "============================================================="
echo "Press Anykey.......................\c"
read dumy
mysqluser.sh
;;
"5")
exit
;;
esac
|