작은숲:위키노트/MySQL root 비밀번호 초기화: 두 판 사이의 차이
보이기
잔글 문자열 찾아 바꾸기 - "분류:공유" 문자열을 "분류:위키노트/공유" 문자열로 |
잔글 Utolee90님이 MySQL root 비밀번호 초기화 문서를 작은숲:위키노트/MySQL root 비밀번호 초기화 문서로 이동했습니다: 제목 변경 |
||
| (같은 사용자의 중간 판 4개는 보이지 않습니다) | |||
| 1번째 줄: | 1번째 줄: | ||
[[위키노트 | [[작은숲:위키노트/MySQL|MySQL]]의 root 비밀번호를 잊어버렸다든지 해서 root 비밀번호를 초기화시켜야 할 때가 있다. 이럴 때는 우선 MySQL 서비스를 중지시킨다. 만약 웹 서비스에서 MySQL을 사용한다면 잠시 [[작은숲:위키노트/웹 서버|웹 서버]]를 내려두는 것이 좋다. MySQL을 사용하는 웹 서비스의 웹 서버를 그대로 두면 아래 작업을 하는 도중 중간중간 MySQL에 접근할 수 없다는 에러 메시지를 출력하게 된다. | ||
< | <syntaxhighlight lang="console"> | ||
# /etc/init.d/mysql stop | # /etc/init.d/mysql stop | ||
Stopping MySQL database server: mysqld. | Stopping MySQL database server: mysqld. | ||
</ | </syntaxhighlight> | ||
그런 후, <code><nowiki>/usr/bin/safe_mysqld</nowiki></code>을 <code><nowiki>--skip-grant</nowiki></code> 옵션을 줘서 실행시키면 권한 테이블을 읽지 않게 된다. 따라서 이제 MySQL에 비밀번호 없이 접근이 가능하다. 하지만, 이것은 대단히 위험한 일이므로 빨리 root 비밀번호를 변경한 다음에는 다시 MySQL을 기동시켜야 한다. <code><nowiki>/usr/bin/safe_mysqld</nowiki></code>을 실행시킬 때는 백그라운드로 실행시킨다. | 그런 후, <code><nowiki>/usr/bin/safe_mysqld</nowiki></code>을 <code><nowiki>--skip-grant</nowiki></code> 옵션을 줘서 실행시키면 권한 테이블을 읽지 않게 된다. 따라서 이제 MySQL에 비밀번호 없이 접근이 가능하다. 하지만, 이것은 대단히 위험한 일이므로 빨리 root 비밀번호를 변경한 다음에는 다시 MySQL을 기동시켜야 한다. <code><nowiki>/usr/bin/safe_mysqld</nowiki></code>을 실행시킬 때는 백그라운드로 실행시킨다. | ||
< | <syntaxhighlight lang="console"> | ||
# /usr/bin/safe_mysqld --skip-grant & | # /usr/bin/safe_mysqld --skip-grant & | ||
[1] 28818 | [1] 28818 | ||
Starting mysqld daemon with databases from /var/lib/mysql | Starting mysqld daemon with databases from /var/lib/mysql | ||
</ | </syntaxhighlight> | ||
이제 MySQL에 들어가서 root 비밀번호를 변경한다. | 이제 MySQL에 들어가서 root 비밀번호를 변경한다. | ||
< | <syntaxhighlight lang="console"> | ||
# mysql -u root mysql | # mysql -u root mysql | ||
Reading table information for completion of table and column names | Reading table information for completion of table and column names | ||
| 25번째 줄: | 25번째 줄: | ||
mysql> quit | mysql> quit | ||
Bye | Bye | ||
</ | </syntaxhighlight> | ||
이제 원하는대로 root 비밀번호를 다시 설정했으니 다시 [[위키노트 | 이제 원하는대로 root 비밀번호를 다시 설정했으니 다시 [[작은숲:위키노트/MySQL|MySQL]] 데몬을 기동시킨다. 이 상태로 그대로 나둔다면 아무나 MySQL에 접근할 수 있으므로 대단히 위험하다. | ||
< | <syntaxhighlight lang="console"> | ||
# /etc/init.d/mysql restart | # /etc/init.d/mysql restart | ||
Stopping MySQL database server: mysqld | Stopping MySQL database server: mysqld | ||
| 33번째 줄: | 33번째 줄: | ||
.Starting MySQL database server: mysqld. | .Starting MySQL database server: mysqld. | ||
[1]+ Done /usr/bin/safe_mysqld --skip-grant | [1]+ Done /usr/bin/safe_mysqld --skip-grant | ||
</ | </syntaxhighlight> | ||
만약 [[위키노트 | 만약 [[작은숲:위키노트/웹 서버|웹 서버]]를 중지시켜놨다니 이제 다시 가동시키도록 하자. | ||
{{MySQL}} | {{MySQL}} | ||
[[분류:위키노트/공유]] | [[분류:위키노트/공유]] | ||
[[분류:서버]] | [[분류:위키노트/서버]] | ||
[[분류:MySQL]]{{퍼온문서|위키노트|{{#invoke:string|replace|{{PAGENAME}}|위키노트:|}}}}[[분류:위키노트에서 가져온 문서]] | [[분류:MySQL]]{{퍼온문서|위키노트|{{#invoke:string|replace|{{PAGENAME}}|위키노트:|}}}}[[분류:위키노트에서 가져온 문서]] | ||
2022년 5월 7일 (토) 15:14 기준 최신판
MySQL의 root 비밀번호를 잊어버렸다든지 해서 root 비밀번호를 초기화시켜야 할 때가 있다. 이럴 때는 우선 MySQL 서비스를 중지시킨다. 만약 웹 서비스에서 MySQL을 사용한다면 잠시 웹 서버를 내려두는 것이 좋다. MySQL을 사용하는 웹 서비스의 웹 서버를 그대로 두면 아래 작업을 하는 도중 중간중간 MySQL에 접근할 수 없다는 에러 메시지를 출력하게 된다.
# /etc/init.d/mysql stop
Stopping MySQL database server: mysqld.그런 후, /usr/bin/safe_mysqld을 --skip-grant 옵션을 줘서 실행시키면 권한 테이블을 읽지 않게 된다. 따라서 이제 MySQL에 비밀번호 없이 접근이 가능하다. 하지만, 이것은 대단히 위험한 일이므로 빨리 root 비밀번호를 변경한 다음에는 다시 MySQL을 기동시켜야 한다. /usr/bin/safe_mysqld을 실행시킬 때는 백그라운드로 실행시킨다.
# /usr/bin/safe_mysqld --skip-grant &
[1] 28818
Starting mysqld daemon with databases from /var/lib/mysql이제 MySQL에 들어가서 root 비밀번호를 변경한다.
# 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 12 to server version: 3.23.49-log
Type 'help;' or 'h' for help. Type 'c' to clear the buffer.
mysql> UPDATE user SET Password = PASSWORD('passwd') WHERE user = 'root';
Query OK, 0 rows affected (0.00 sec)
Rows matched: 2 Changed: 0 Warnings: 0
mysql> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.00 sec)
mysql> quit
Bye이제 원하는대로 root 비밀번호를 다시 설정했으니 다시 MySQL 데몬을 기동시킨다. 이 상태로 그대로 나둔다면 아무나 MySQL에 접근할 수 있으므로 대단히 위험하다.
# /etc/init.d/mysql restart
Stopping MySQL database server: mysqld
020811 18:28:41 mysqld ended
.Starting MySQL database server: mysqld.
[1]+ Done /usr/bin/safe_mysqld --skip-grant만약 웹 서버를 중지시켜놨다니 이제 다시 가동시키도록 하자.
| 설정과 문제 해결 | |
|---|---|
| 활용 | |