Mysql root 암호 초기화 방법

Windows 기준입니다.

 

1.

먼저 mysql 관련 프로세스를 모두 종료합니다.

mysql.exe, mysqld.exe, mysqlc.exe 등 모두 종료해야 합니다.

 

 

2.

실행 창에서 cmd 또는 command 로 코맨드 창을 2개 엽니다.

 

첫번째 창에는 아래와 같은 명령으로 암호 없이 mysql 에 접속가능하게 합니다.

mysqld --skip-grant

 

 

 

 

 

 

두 번째 창에서 root 암호를 변경해 줍니다.

 

c:\>mysql

mysql>mysql -uroot mysql

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

mysql>flush privileges;

mysql>quit

 

 

 

새로운 암호로 로그인을 확인해 봅니다.

 

 

Microsoft Windows [Version 5.2.3790]

(C) Copyright 1985-2003 Microsoft Corp.

 

C:\Documents and Settings\Administrator>mysql

ERROR 1045 (28000): Access denied for user 'ODBC'@'localhost' (using password: N

O)

 

C:\Documents and Settings\Administrator>mysql -uroot mysql

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

Your MySQL connection id is 7

Server version: 5.1.41-community MySQL Community Server (GPL)

 

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

 

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

Query OK, 1 row affected (0.19 sec)

Rows matched: 1  Changed: 1  Warnings: 0

 

mysql>

mysql> flush privileges;

Query OK, 0 rows affected (0.00 sec)

 

mysql> quit

Bye

 

C:\Documents and Settings\Administrator>

 

 

 

+ Recent posts