현재의 mysql 패스워드를 모를때 변경할수 있는 shell
=============================================================
==========================================
#!/bin/sh
echo "mysql 데몬을 중지 합니다"
pkill mysqld
sleep 4
echo "mysql 데몬을 시작 합니다"
/usr/local/mysql/bin/mysqld_safe --skip-grant &
sleep 4
echo " "
echo "mysql 패스워드를 변경합니다."
echo " "
echo "변경할 mysql root 패스워드를 입력하시오"
read newpassword
echo "use mysql;
update user set password=password('$newpassword') where user='root';
flush privileges;" > insert_query
echo " "
/usr/local/mysql/bin/mysql -u root < insert_query
rm -rf insert_query
echo "mysql 데몬을 중지 합니다"
pkill mysqld
sleep 4
echo "mysql 데몬을 시작 합니다"
/usr/local/mysql/bin/mysqld_safe &
sleep 4
echo " "
echo "mysql 패스워드가 $newpassword로 변경되었습니다"
echo " "
=============================================================
==========================================
#!/bin/sh
echo "mysql 데몬을 중지 합니다"
pkill mysqld
sleep 4
echo "mysql 데몬을 시작 합니다"
/usr/local/mysql/bin/mysqld_safe --skip-grant &
sleep 4
echo " "
echo "mysql 패스워드를 변경합니다."
echo " "
echo "변경할 mysql root 패스워드를 입력하시오"
read newpassword
echo "use mysql;
update user set password=password('$newpassword') where user='root';
flush privileges;" > insert_query
echo " "
/usr/local/mysql/bin/mysql -u root < insert_query
rm -rf insert_query
echo "mysql 데몬을 중지 합니다"
pkill mysqld
sleep 4
echo "mysql 데몬을 시작 합니다"
/usr/local/mysql/bin/mysqld_safe &
sleep 4
echo " "
echo "mysql 패스워드가 $newpassword로 변경되었습니다"
echo " "