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>
번호 제목 글쓴이 날짜 조회 수
25 [MySQL] 무한정 늘어나는 log-bin 파일 줄이기 호스트웨이 2012.11.23 7057
24 phpmyadmin에서 'mcrypt 확장모듈을 불러올 수 없습니다' 에러 시 file 호스트웨이 2012.11.29 6660
23 mysql-5.5.x 에서 character-set 변경 호스트웨이 2012.12.07 7200
22 MySQL에서 Query Cache 사용하기 호스트웨이 2012.12.20 7088
21 innodb 설치 및 옵션 호스트웨이 2014.04.14 23373
20 MariaDB, MySQL 의 InnoDB 엔진 백업 솔루션 xtrabackup 호스트웨이 2015.05.07 13867
19 Ubuntu mysql 삭제/재설치 호스트웨이 2015.09.04 16828
18 MySQL Processlist 콘솔 상에서 확인 호스트웨이 2015.09.07 6060
17 MySQL 보안을 위한 전용관리계정으로 MySQL 관리하기 호스트웨이 2015.09.08 8957
16 MYSQL-날짜 관련 함수 모음 호스트웨이 2015.09.09 40681
15 mysql replication을 이용한 DB 백업 동기화 에러 발생시 (slave db 1062 error) 호스트웨이 2015.09.09 8981
14 MYSQL의 "too many connections" 에러 해결법 호스트웨이 2015.09.10 11793
13 MySQL Table 상태 확인, 복구 및 최적화 호스트웨이 2015.09.11 10901
12 지정된 시간 이상 질의를 계속 하는 질의문 잡아내기 호스트웨이 2015.09.15 6042
11 MYSQL 동시접속자수 늘리기 호스트웨이 2015.09.18 7320
10 MySQL DB 옵티마이저 사용법 호스트웨이 2015.09.18 6858
9 [mysql] shell 자동화 호스트웨이 2015.09.20 6329
8 [mysql] table 백업 호스트웨이 2015.09.21 7801
7 [mysql] /tmp/mysql.sock이 없다고 DB접속이 안되는 경우 호스트웨이 2015.09.21 11173
6 [mysql] sqli, pdo 설정 확인 호스트웨이 2015.09.22 6597