2012-10-06

[DBMS/MySQL]root_패스워드_잊어_버린_경우_새로_설정하는_방법


mysql을 오랫동안 사용하지 않았을 경우에 간혹 root패스워드가 기억나질않아서 당황할 때가 있습니다.
특히, 여러대의 시스템을 관리할 경우에는 시스템의 root패스워드와 일반계정 및 MySQL의 root계정과 일반계정등 기억해야할 암호가 수십개씩 되는 경우가 흔히 있습니다.
필자의 경우에도 관리하는 서버가 많은 편에 속하기 때문에 패스워드를 전혀 바꾸지 않을 수는 없고 해서 변경한 후에는 메모하여 잘 보지 못하는 곳에 블랙박스로 보관합니다.
시스템의 root암호를 잊어 버린 경우도 있었으며, MySQL의 root사용자의 암호를 잊어 버린 경험도 많이 있었습니다.
경험있는 시스템관리자라면 시스템의 root나 MySQL의 root의 암호를 잊어 버렸을 때를 대비해서 패스워드를 새로 설정하는 방법을 반드시 숙지하고 있어야 할 것입니다.





 

1. 실행중인 msyql 종료

[root@kebia_1 bin]# ps -ef | grep mysqld
root956710 Mar16 ?00:00:00 sh ./safe_mysqld
root957695670 Mar16 ?00:00:00 /usr/local/mysql/libexec/mysqld
root957895760 Mar16 ?00:00:00 /usr/local/mysql/libexec/mysqld
root957995780 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: 3Changed: 3Warnings: 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
root12084 115580 20:10 pts/200:00:00 sh ./safe_mysqld --skip-grant-ta
root12090 120840 20:10 pts/200:00:00 /usr/local/mysql/libexec/mysqld
root12092 120900 20:10 pts/200:00:00 /usr/local/mysql/libexec/mysqld
root12093 120920 20:10 pts/200: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
root12102 115580 20:13 pts/200:00:00 sh ./safe_mysqld
root12108 121020 20:13 pts/200:00:00 /usr/local/mysql/libexec/mysqld
root12110 121080 20:13 pts/200:00:00 /usr/local/mysql/libexec/mysqld
root12111 121100 20:13 pts/200:00:00 /usr/local/mysql/libexec/mysqld
[root@kebia_1 bin]#

댓글 없음:

댓글 쓰기