반응형
MySQL 사용자 비밀번호 변경
MySQL 사용자 비밀번호 변경
mysql>update user set password=password('비밀번호') where user='아이디';
mysql>flush privileges;
mysql>flush privileges;
mysql PATH
echo PATH=$PATH:/usr/local/mysql/bin >> /etc/profile && source /etc/profile
mysql-opt
#!/bin/sh
./configure --prefix=/usr/local/mysql --with-charset=euc_kr --without-debug
make
make install
~
~
~
~
~
~
./configure --prefix=/usr/local/mysql --with-charset=euc_kr --without-debug
make
make install
~
~
~
~
~
~
mysql 계정생성
$1: 디비명, $2: 디비아이디, $3: 디비비밀번호
### 디비계정 발급 ###
create database $1;
insert into db values('localhost','$1','$2','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y');"
insert into user values('localhost','$2',password('$3'),'N','N','N','N','N','N','N','N','N','N','N','N','N','N');"
### 디비계정 발급 ###
create database $1;
insert into db values('localhost','$1','$2','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y');"
insert into user values('localhost','$2',password('$3'),'N','N','N','N','N','N','N','N','N','N','N','N','N','N');"
mysql 계정생성 및 삭제(스크립트)
########################## 계정생성 ##########################
[root@server mysql]# vi create_db.sh
#!/bin/bash
# $1 : db_name
# $2 : db_id
# $3 : db_password
if [ "$3" != "" ]; then
touch /tmp/mysql_dbusersetup_temp
echo "create database $1;" >> /tmp/mysql_dbusersetup_temp
echo "insert into db values('localhost','$1','$2','y','y','y','y','y','y','y','y','y','y');" >> /tmp/mysql_dbusersetup_temp
echo "insert into user values('localhost','$2',password('$3'),'n','n','n','n','n','n','n','n','n','n','n','n','n','n');" >> /tmp/mysql_dbusersetup_temp
echo "MYSQL 관리자 패스워드"
/usr/local/mysql/bin/mysql -u root -p mysql < /tmp/mysql_dbusersetup_temp
rm -f /tmp/mysql_dbusersetup_temp
echo "MYSQL 관리자 패스워드 입력2"
/usr/local/mysql/bin/mysqladmin -u root -p reload
else
echo "USAGE: $0 DB명 DB아이디 DB비밀번호"
echo ""
fi
exit 0
~
~
~
~
~
~
~
~
[root@server mysql]#
########################## 계정삭제 ##########################
[root@server mysql]# vi delete_db.sh
#! /bin/bash
# $1 : db_name
# $2 : db_id
if [ "$2" != "" ]; then
touch /tmp/mysql_dbuserdel_temp
echo "drop database $1;" >> /tmp/mysql_dbuserdel_temp
echo "delete from db where user = '$2';" >> /tmp/mysql_dbuserdel_temp
echo "delete from user where user = '$2';" >> /tmp/mysql_dbuserdel_temp
echo "MYSQL 관리자 패스워드 입력"
/usr/local/mysql/bin/mysql -u root -p mysql < /tmp/mysql_dbuserdel_temp
rm -f /tmp/mysql_dbuserdel_temp
echo "MYSQL 관리자 패스워드 입력2"
/usr/local/mysql/bin/mysqladmin -u root -p reload
else
echo "USAGE: $0 db명 db아이디"
echo ""
fi
exit 0
~
~
~
~
~
~
~
[root@server mysql]#
[root@server mysql]# vi create_db.sh
#!/bin/bash
# $1 : db_name
# $2 : db_id
# $3 : db_password
if [ "$3" != "" ]; then
touch /tmp/mysql_dbusersetup_temp
echo "create database $1;" >> /tmp/mysql_dbusersetup_temp
echo "insert into db values('localhost','$1','$2','y','y','y','y','y','y','y','y','y','y');" >> /tmp/mysql_dbusersetup_temp
echo "insert into user values('localhost','$2',password('$3'),'n','n','n','n','n','n','n','n','n','n','n','n','n','n');" >> /tmp/mysql_dbusersetup_temp
echo "MYSQL 관리자 패스워드"
/usr/local/mysql/bin/mysql -u root -p mysql < /tmp/mysql_dbusersetup_temp
rm -f /tmp/mysql_dbusersetup_temp
echo "MYSQL 관리자 패스워드 입력2"
/usr/local/mysql/bin/mysqladmin -u root -p reload
else
echo "USAGE: $0 DB명 DB아이디 DB비밀번호"
echo ""
fi
exit 0
~
~
~
~
~
~
~
~
[root@server mysql]#
########################## 계정삭제 ##########################
[root@server mysql]# vi delete_db.sh
#! /bin/bash
# $1 : db_name
# $2 : db_id
if [ "$2" != "" ]; then
touch /tmp/mysql_dbuserdel_temp
echo "drop database $1;" >> /tmp/mysql_dbuserdel_temp
echo "delete from db where user = '$2';" >> /tmp/mysql_dbuserdel_temp
echo "delete from user where user = '$2';" >> /tmp/mysql_dbuserdel_temp
echo "MYSQL 관리자 패스워드 입력"
/usr/local/mysql/bin/mysql -u root -p mysql < /tmp/mysql_dbuserdel_temp
rm -f /tmp/mysql_dbuserdel_temp
echo "MYSQL 관리자 패스워드 입력2"
/usr/local/mysql/bin/mysqladmin -u root -p reload
else
echo "USAGE: $0 db명 db아이디"
echo ""
fi
exit 0
~
~
~
~
~
~
~
[root@server mysql]#
반응형
'MySQL' 카테고리의 다른 글
MySQL 계정 삭제(DB명, DB아이디) (0) | 2011.04.27 |
---|---|
MySQL을 소스로 컴파일 했을 경우 시스템 재부팅시 자동으로 시작하기 (0) | 2011.04.27 |
MySQL의 데이터는 어디에 저장되나? & 관리자 비번을 잊었을때는? & 백업 (0) | 2011.04.26 |
컴파일후 MySQL실행 $PATH지정하기 (0) | 2011.04.26 |
MySQL root 패스워드 분실시 방법 (0) | 2011.04.26 |