Linux DB

MySQL 비밀번호 분실 했을 때

2008.05.15 00:38

sylee 조회 수:22681

1. MySQL 데몬을 중지 시킨다.

[root@localhost mysql]# killall mysqld (또는 pkill -9 mysqld)

2. --skip-grant 옵션을 주어서 mysql 데몬은 다시 실행시킨다.

[root@localhost mysql]# /usr/local/mysql/bin/safe_mysqld --skip-grant &
Starting mysqld daemon with databases from /usr/local/mysql/var

3. 패스워드 없이 root 계정으로 mysql에 접속한다.

[root@localhost mysql]# ./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 970 to server version: 3.22.32

Type 'help' for help.

mysql>

4. mysql> 프롬프트에서 update 쿼리문으로 패스워드를 재설정 한다.

mysql> UPDATE user SET Password=PASSWORD('newpasswd') WHERE user='root';

Query OK, 1 row affected (0.01 sec)
Row matched:2 Changed: 1 Warnungs: 0

5. 변경사항은 적용시킨다.

mysql> FLUSH PRIVILEGES;

Query OK, 0 rows affected (0.05 sec)


6. mysql> 프롬프트에서 빠져 나온다.

mysql> quit

Bye

7. mysql 데몬을 재시작 한다.

[root@localhost mysql]# killall mysqld (또는 pkill -9 mysqld)
[root@localhost mysql]# /usr/local/mysql/bin/safe_mysqld &
[1] 10008
[root@localhost mysql]# Starting mysqld daemon with databases from /usr/local/mysql/data

8. 업데이트한 패스워드로 mysql에 접속한다.

[root@localhost mysql]# /usr/local/mysql/bin/mysql -u root -p
Enter password: ******
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.32

Type 'help' for help.

mysql>
번호 제목 글쓴이 날짜 조회 수
45 MySQL 원격 접속이 이뤄지지 않는다면? 호스트웨이 2012.07.13 10736
44 MySQL Table 상태 확인, 복구 및 최적화 호스트웨이 2015.09.11 10870
43 Mysql DB 생성 및 사용자 추가 호스트웨이 2012.03.23 11144
42 [mysql] /tmp/mysql.sock이 없다고 DB접속이 안되는 경우 호스트웨이 2015.09.21 11166
41 MySQL 설치 시 checking "LinuxThreads"… "Not found" 에러 발생 시 호스트웨이 2012.09.21 11308
40 mysql 로그 삭제하기 호스트웨이 2012.07.20 11488
39 Mysql banchmark tool – sysbanch 설치하기 호스트웨이 2012.07.06 11543
38 MYSQL의 "too many connections" 에러 해결법 호스트웨이 2015.09.10 11789
37 MySQL Bash 스크립트를 활용한 로컬 백업 호스트웨이 2016.02.04 12399
36 안전한 MySQL 접속하기 file 호스트웨이 2012.06.22 13055
35 MariaDB, MySQL 의 InnoDB 엔진 백업 솔루션 xtrabackup 호스트웨이 2015.05.07 13861
34 Mysql - 원격 접속 지연 발생시 호스트웨이 2012.08.03 14013
33 심볼릭 링크를 이용한 mysql 데이터 디렉토리 위치 변경 호스트웨이 2012.03.23 14299
32 MySQL-5.5 설치하기 호스트웨이 2012.04.27 15711
31 Ubuntu mysql 삭제/재설치 호스트웨이 2015.09.04 16825
30 DB접속시 DNS 관련 오류 호스트웨이 2015.09.25 18224
29 MySQL Table 이 깨졌을 때 복구하는 방법 호스트웨이 2012.03.16 18651
28 mysql의 table이 깨졌다는 메시지가 출력됩니다. sylee 2008.05.15 18875
27 show processlist의 state 종류 호스트웨이 2012.05.11 19210
26 My SQL 사용자 추가 호스트웨이 2008.05.19 19265