mysql root 패스워드 분실시 새로 설정하는 방법 > MySQL

STUDY ROOM

MySQL

mysql root 패스워드 분실시 새로 설정하는 방법

페이지 정보

작성자 JMStudy 작성일05-07-07 19:11 조회6,538회 댓글0건

본문

mysql을 오랫동안 사용하지 않았을 경우에 간혹 root패스워드가 기억나질않아서 당황할 때가 있습니다.

특히, 여러대의 시스템을 관리할 경우에는 시스템의 root패스워드와 일반계정 및 MySQL의 root계정과 일반계정등 기억해야할 암호가 수십개씩 되는 경우가 흔히 있습니다.

필자의 경우에도 관리하는 서버가 많은 편에 속하기 때문에 패스워드를 전혀 바꾸지 않을 수는 없고 해서 변경한 후에는 메모하여 잘 보지 못하는 곳에 블랙박스로 보관합니다.

시스템의 root암호를 잊어 버린 경우도 있었으며, MySQL의 root사용자의 암호를 잊어 버린 경험도 많이 있었습니다.

경험있는 시스템관리자라면 시스템의 root나 MySQL의 root의 암호를 잊어 버렸을 때를 대비해서 패스워드를 새로 설정하는 방법을 반드시 숙지하고 있어야 할 것입니다.

1. 실행중인 msyql 종료

[root@kebia_1 bin]# ps -ef | grep mysqld

root 9567 1 0 Mar16 ? 00:00:00 sh ./safe_mysqld

root 9576 9567 0 Mar16 ? 00:00:00 /usr/local/mysql/libexec/mysqld

root 9578 9576 0 Mar16 ? 00:00:00 /usr/local/mysql/libexec/mysqld

root 9579 9578 0 Mar16 ? 00:00:00 /usr/local/mysql/libexec/mysqld

[root@kebia_1 bin]#

[root@kebia_1 bin]# killall mysqld

[root@kebia_1 bin]#



2. grant-table 미사용모드로 mysql시작


[root@kebia_1 bin]# ./safe_mysqld --skip-grant-tables&

[1] 12084

[root@kebia_1 bin]# Starting mysqld daemon with databases from /usr/local/mysql/data


[root@kebia_1 bin]#

[root@kebia_1 bin]# ./mysql -u root mysql

Reading table information for completion of table and column names

You can turn off this feature to get a quicker startup with -A

Welcome to the MySQL monitor. Commands end with ; or \g.

Your MySQL connection id is 1 to server version: 3.22.24


Type 'help' for help.

mysql>


3. update문으로 root사용자 패스워드 변경


mysql> update user set password=password('12345') where user = 'root';

Query OK, 3 rows affected (0.00 sec)

Rows matched: 3 Changed: 3 Warnings: 0

mysql> flush privileges;

Query OK, 0 rows affected (0.01 sec)

mysql> exit

Bye



4. 실행중인 mysql 다시 종료

[root@kebia_1 bin]# ps -ef | grep mysqld

root 12084 11558 0 20:10 pts/2 00:00:00 sh ./safe_mysqld --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

[root@kebia_1 bin]#

[root@kebia_1 bin]# killall mysqld

mysqld daemon ended

[1]+ Done ./safe_mysqld --skip-grant-tables

[root@kebia_1 bin]#



5. 일반모드로 Mysql 재시작


[root@kebia_1 bin]# ./safe_mysqld&

[1] 12102

[root@kebia_1 bin]# Starting mysqld daemon with databases from /usr/local/mysql/data

[root@kebia_1 bin]#

[root@kebia_1 bin]# ps -ef | grep mysql

root 12102 11558 0 20:13 pts/2 00:00:00 sh ./safe_mysqld

root 12108 12102 0 20:13 pts/2 00:00:00 /usr/local/mysql/libexec/mysqld

root 12110 12108 0 20:13 pts/2 00:00:00 /usr/local/mysql/libexec/mysqld

root 12111 12110 0 20:13 pts/2 00:00:00 /usr/local/mysql/libexec/mysqld

[root@kebia_1 bin]#
댓글목록

등록된 댓글이 없습니다.