메뉴 건너뛰기

리눅스 관련 모음

본문시작

?

단축키

Prev이전 문서

Next다음 문서

크게 작게 위로 아래로 댓글로 가기 인쇄
?

단축키

Prev이전 문서

Next다음 문서

크게 작게 위로 아래로 댓글로 가기 인쇄

국산 통나무 수공예 남원제기, 남원목기

자료가 도움이 되셨다면
혼수용품제수용품 필요시
남원제기 공식 홈페이지 http://남원제기.kr
남원목기 공식 홈페이지 http://otchil.kr
에서 구매 해 주세요
정성껏 모시겠습니다.
 

[Mysql] password설정 및 변경, root 비번 잃어버렸을 경우 변경법


1. 초기 mysql root 패스워드 설정하기
mysql 서버에 패스워드 없이 로그인 하게되면 서버에 만들어진 데이터베이스나 테이블
기타 이곳에 저장된 자료가 외부인에게 노출될 수 있다. 따라서 이러한 보안을 목적으로
root 패스워드를 지정하면 mysql 서버를 안전하게 보호할 수 있다.

mysql> use  mysql;
mysql> update  user  set  password=password('123456') where user='root';
Query OK, 2 rows affected (0.03 sec)
Rows matched: 2  Changed: 2  Warnings: 0
mysql> flush  privileges; <--- 적용
flush privileges; 를 하지 않으면 mysql에서 빠져나와서 root 로그인이 안된다.
확인한다.
mysql> select  host, user, password  from  user;
+----------------------------------------------------------------+
| Host                          user              password       |
+----------------------------------------------------------------+
| localhost                     root          2e01146f5c065853   |
| localhost.localdomain         root          2e01146f5c065853   |
+----------------------------------------------------------------+

mysql> q
Bye
------------------------------------------------------------------------------------
[주의]# mysql -u root -p
Enter password:
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)
그대는 mysql 을 shutdown 하거나 reload 하면 된다.
# /usr/local/mysql/bin/mysqladmin -u root -p shutdown
하면 패스워드를 묻는데 이때 입력하면 설정한 mysql이 적용이된다.
# /usr/local/mysql/bin/mysqladmin -u root -p reload;
------------------------------------------------------------------------------------

# mysql -u root -p [Enter]       //  root 패스워드로 로그인
Enter password: ******

※ Mysql 서버에 root 패스워드가 설정되면 이제 부터는 mysql 서버에 접속하기 위해서는
위와 같이 -u 뒤에 root입력하고 -p 옵션을 사용하여 패스워드를 사용한다는 것을 명시해야 한다.
그리고 엔터를 치면 root 패스워드를 입력받기 위해 커서가 멈춘다.
(mysql 명령어만 입력하고 엔터를 치면 패스워드를 묻지 앟고 바로 mysql> 프롬프트가 나온 옛 시절을 생각해 보면 금방 차이를 느낄수 있음) 

2. 루트 비번 변경
mysql> use  mysql;
mysql> update  user  set  password=password('123456') where user='root';
mysql> flush  privileges;

3. root 패스워드를 분실한 경우(응급조치)

mysql을 오랫동안 사용하지 않았을 경우에 간혹 root패스워드가 기억나질않아서 당황할 때가 있습니다.  시스템관리자라면 시스템의 root나 MySQL의 root의 암호를 잊어 버렸을 때를 대비해서 패스워드를 새로 설정하는 방법을 반드시 숙지하고 있어야 할 것입니다.

① 실행중인 msyql 종료

# ps -ef | grep mysqld
root      9567     1  0 Mar16 ?        00:00:00 sh ./mysqld_safe
root      9576  9567  0 Mar16 ?        00:00:00 /usr/local/mysql/libexec/mysqld
root      9578  9576  0 Mar16 ?        00:00:00 /usr/local/mysql/libexec/mysqld
root      9579  9578  0 Mar16 ?        00:00:00 /usr/local/mysql/libexec/mysqld

# killall mysqld

② grant-table 미사용모드로 mysql시작(권한 테이블을 사용하지 않는 옵션으로 데몬 실행)

# ./safe_mysqld  --skip-grant-tables &
[1] 12084
# Starting mysqld daemon with databases from /usr/local/mysql/data
#

# ./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 1 to server version: 3.22.24
Type 'help' for help.
mysql>

※ mysqld_safe 명령어는 mysql 데몬을 실행시킨다.

③ update문으로 root사용자 패스워드 갱신

mysql> update user set password=password('123') where user = 'root';
Query OK, 3 rows affected (0.00 sec)
Rows matched: 3  Changed: 3  Warnings: 0
mysql> flush privileges;
Query OK, 0 rows affected (0.01 sec)
mysql> q         
Bye

④ 실행중인 mysql 다시 종료(권한 테이블을 사용하지 않는 데몬을 종료)

# ps -ef | grep mysqld
root     12084 11558  0 20:10 pts/2    00:00:00 sh ./mysqld_safe --skip-grant-ta
root     12090 12084  0 20:10 pts/2    00:00:00 /usr/local/mysql/libexec/mysqld
root     12092 12090  0 20:10 pts/2    00:00:00 /usr/local/mysql/libexec/mysqld
root     12093 12092  0 20:10 pts/2    00:00:00 /usr/local/mysql/libexec/mysqld
#
# killall mysqld
mysqld daemon ended
[1]+  Done                    ./mysqld_safe --skip-grant-tables
#

⑤  Mysql 데몬 재 실행 후 갱신된 패스워드로 로그인

# ./safe_mysqld &
[1] 12102
# Starting mysqld daemon with databases from /usr/local/mysql/data
#

# ps -ef | grep mysql
root     12102 11558  0 20:13 pts/2    00:00:00 sh ./mysqld_safe
root     12108 12102  0 20:13 pts/2    00:00:00 /usr/local/mysql/libexec/mysqld
root     12110 12108  0 20:13 pts/2    00:00:00 /usr/local/mysql/libexec/mysqld
root     12111 12110  0 20:13 pts/2    00:00:00 /usr/local/mysql/libexec/mysqld

# mysql -u  root  -p
Enter Password: ***************

   

List of Articles
번호 분류 제목 글쓴이 날짜 조회 수
190 - FQDN - 올바른 Hostname 설정하기. 햇빛소년 2012.06.02 32826
189 설치관련 .htaccess 이용 스팸 IP 차단 햇빛소년 2013.01.17 25199
188 에러해결 'post-create' on '/var/spool/abrt/................................... secret 햇빛소년 2013.08.28 0
187 [1원짜리 팁] hosts.deny 햇빛소년 2011.05.11 51435
186 설치관련 [bind] DNSSEC 구축방법 file 햇빛소년 2013.07.07 16474
185 설치관련 [Linux Password 정책변경] linux 비밀번호 md5에서 SHA-512로 변경하기 secret 햇빛소년 2013.06.30 0
184 에러해결 [MySQL] Incorrect integer value: '' for column '컬럼명' 오류 발생시 햇빛소년 2013.06.19 17443
» [Mysql] password설정 및 변경, root 비번 잃어버렸을 경우 변경법 햇빛소년 2011.03.20 51422
182 에러해결 [mysql] 에러 메세지 - RSA private key file not found: /mysql/data//private_key.pem. Some authentication plugins will not work. secret 햇빛소년 2014.01.20 1
181 에러해결 [mysql] 에러메세지 - [Note] Plugin 'FEDERATED' is disabled. 햇빛소년 2014.01.20 6868
180 에러해결 [mysql]에러 메세지- #1146 - Table 'mysql.innodb_index_stats' doesn't exist 해결 secret 햇빛소년 2014.01.17 157
179 에러해결 [sendmail: clamav-milter error] Milter: data, reject=451 4.3.2 Please try again later 햇빛소년 2013.06.27 16906
178 에러해결 [win8] 호스트된 네트워크를 시작할 수 없습니다. 햇빛소년 2014.10.30 3682
177 설치관련 /etc/init.d/proftpd 실행 스크립트 secret 햇빛소년 2013.06.19 0
176 /etc/mail/access 사용법 햇빛소년 2012.06.22 31288
175 /etc/rc.d/init.d/smb script file 햇빛소년 2012.07.02 29199
174 /etc/security/pam_env.conf: No such file or directory 햇빛소년 2012.06.18 30136
173 에러해결 abrt 에러 메세지 /var/log/messages 햇빛소년 2014.05.16 8516
172 Amavisd 에서 spam filtering 수준 조절 햇빛소년 2011.04.09 72542
171 Apache 2.4.1 소스설치시 에러에 대한 해결 햇빛소년 2012.02.26 58251
Board Pagination Prev 1 2 3 4 5 6 7 8 9 10 Next
/ 10