mysql root recover

Step # 1 : Stop mysql service
# /etc/init.d/mysqld stop

Output:
Stopping MySQL database server: mysqld./

Step # 2: Start to MySQL server w/o password:
# mysqld_safe –skip-grant-tables &

Output:
[1] 5988
Starting mysqld daemon with databases from /var/lib/mysql
mysqld_safe[6025]: started

Step # 3: Connect to mysql server using mysql client:
# mysql -u root

Output:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 1 to server version: 4.1.15-Debian_1-log
Type ‘help;’ or ‘\h’ for help. Type ‘\c’ to clear the buffer.
mysql>

Step # 4: Setup new MySQL root user password (특수문자 불가 !@#$%^&*)
mysql> use mysql;
mysql> update user set password=PASSWORD(“NEW-ROOT-PASSWORD”) where User=’root’;
mysql> flush privileges;
mysql> quit

추가
Step # 5
실행중인 mysql 다시 종료(* 중요 : 권한 테이블을 사용하지 않는 데몬을 종료) 하지 않으면 mysql 하면 바로 들어감

# ps -ef | grep mysqld
root 12084 11558 0 20:10 pts/2 00:00:00 sh ./mysqld_safe –skip-grant-ta
root 12090 12084 0 20:10 pts/2 00:00:00 /usr/local/mysql/libexec/mysqld
root 12092 12090 0 20:10 pts/2 00:00:00 /usr/local/mysql/libexec/mysqld
root 12093 12092 0 20:10 pts/2 00:00:00 /usr/local/mysql/libexec/mysqld
#
# killall mysqld
mysqld daemon ended
[1]+ Done ./mysqld_safe –skip-grant-tables
#

Step # 6
Mysql 데몬 재 실행 후 갱신된 패스워드로 로그인

* Test
: Start MySQL server and test it
# /etc/init.d/mysqld start
# mysql -u root -p

실수로 계정 삭제시 :