■ Windows OS에 설치된 mysql서버의 root 계정의 비밀번호 분실시 이를 변경하는 방법을 알아본다. 여기서는 3개의 도스창(명령 프롬프트)가 필요하다. 비인증모드로 mysql서버를 실행시키기 위한 도스창, mysql root 비밀번호를 변경하고 권한 적용하기 위한 도스창, 비인증모드로 실행한 mysql서버를 중지시키기 위한 도스창이 필요하다.
■ 먼저 서비스에서 실행중인 mysql 서버가 있다면 서버를 중지한다.
■ 서비스에 등록된 mysql 실행파일 경로를 참조하여 비인증모드(–skip-grant)로 mysql 서버를 실행한다. (DOS창은 관리자 모드로 실행해서 열어야 함)
C:\Windows\system32>mysqld --defaults-file="C:\ProgramData\MySQL\MySQL Server 5.6\my.ini" --skip-grant
■ mysql 명령어를 이용하여 -p옵션없이 mysql 서버에 접속한다(mysql 데이터베이스에 접속). 비인증모드(–skip-grant)로 mysql 서버를 실행하였기 때문에 패스워드를 입력하는 -p 옵션이 없다. mysql 데이터베이스에 접속 후 update 쿼리를 이용해서 root사용자의 비밀번호를 변경한다. 그리고 변경된 root 사용자정보를 권한 적용한다.(flush privileges)
C:\Users\nextman-note>mysql -u root mysql --port 3306 --host localhost Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 1 Server version: 5.6.21-log MySQL Community Server (GPL) Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. mysql> update user set password=password('변경할 비밀번호') where user='root'; Query OK, 3 rows affected (0.01 sec) Rows matched: 3 Changed: 3 Warnings: 0 mysql> flush privileges; Query OK, 0 rows affected (0.01 sec) mysql> quit Bye C:\Users\nextman-note>
■ 비밀번호를 변경하기 위해 임시로 시작한 mysql서버를 종료해야 하는데 비밀번호를 변경 후 서버를 종료시에는 아래와 같이 비밀번호를 입력하여야 종료 된다.
C:\Users\nextman-note>mysqladmin -u root shutdown -p Enter password: ***** C:\Users\nextman-note>
■ 윈도우 서비스에서 중지한 mysql 서버를 시작하면 mysql root 비밀번호 변경이 완료된다.
- mysql 비밀번호 설정 2014년 10월 13일
- MySQL Workbench 단축키(shortcuts) 2015년 7월 10일
- mysql backup script(mysql 백업 스크립트) 2015년 7월 13일
- mysql 환경변수(mysql variables) 2015년 7월 16일
- mysql yum install 2015년 8월 2일
- MySQL DB생성, 사용자 추가 2015년 8월 2일
- MySQL 테이블 생성 예제 2015년 8월 2일
- MySQL 명령어 모음 2016년 2월 22일
- MySQL 에러 메세지 2016년 2월 22일
- MySQL 원격 접속 사용자 추가 2016년 2월 22일
- MySQL root 비밀번호 변경 2016년 2월 23일
- MySQL my.ini, my.cnf 위치 2016년 2월 24일
- MySQL 백업 및 복구 2016년 3월 7일
- MySQL 수학함수 2016년 3월 9일
- MySQL Data Type – DATE와 DATETIME 2016년 3월 14일
- MySQL DDL 2016년 3월 14일
- MySQL Index 2016년 5월 25일
- 콘솔에서 mysql 서버 접속방법 2016년 10월 25일
- mysql 일반사용자 비밀번호 변경 2016년 10월 25일
- MySQL Error Log 위치 2018년 2월 13일