MySQL Password 복구방법
1. 기존의 동작 중이던 프로세스(데몬)을 종료 시킨다.
2. # mysqld_safe --skip-grant &
명령을 이용하여 안전모드로 동작시킨다.
3. # mysql 명령만으로 접속이 가능하다.
4. 실행 이후 과정
mysql> USE mysql;
mysql> UPDATE user SET password=PASSWORD("패스워드") WHERE host="localhost";
mysql> flush privileges;
mysql> exit
login as: root
root@192.168.2.154's password:
Last login: Thu Dec 4 10:04:38 2014 from 192.168.2.104
[root@ns ~]# mysql
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)
[root@ns ~]# service mysql stop
Shutting down MySQL.. [ OK ]
[root@ns ~]# mysql_
mysql_config_editor mysql_fix_extensions mysql_secure_installation mysql_upgrade
mysql_convert_table_format mysql_install_db mysql_setpermission mysql_waitpid
mysql_find_rows mysql_plugin mysql_tzinfo_to_sql mysql_zap
[root@ns ~]# mysqld_safe --skip-grant
141204 12:06:08 mysqld_safe Logging to '/var/lib/mysql/ns.dss.or.kr.err'.
141204 12:06:08 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql
[1]+ Stopped mysqld_safe --skip-grant
[root@ns ~]# bg
[1]+ mysqld_safe --skip-grant &
[root@ns ~]# jobs
[1]+ Running mysqld_safe --skip-grant &
[root@ns ~]# kill %1
[root@ns ~]# 141204 12:06:37 mysqld_safe mysqld from pid file /var/lib/mysql/ns.dss.or.kr.pid ended
[1]+ Done mysqld_safe --skip-grant
[root@ns ~]# ps aux | grep mysql
root 7637 0.0 0.1 5236 668 pts/1 R+ 12:07 0:00 grep mysql
[root@ns ~]# mysqld_safe --skip-grant &
[1] 7650
[root@ns ~]# 141204 12:08:02 mysqld_safe Logging to '/var/lib/mysql/ns.dss.or.kr.err'.
141204 12:08:02 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql
[root@ns ~]# jobs
[1]+ Running mysqld_safe --skip-grant &
[root@ns ~]# mysql
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.6.22 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>
mysql> use mysql;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Database changed
mysql> update user set password=password("123") where host="localhost";
Query OK, 1 row affected (0.10 sec)
Rows matched: 1 Changed: 1 Warnings: 0
mysql> flush privileges;
Query OK, 0 rows affected (0.02 sec)
mysql> exit
Bye
[root@ns ~]#
'Mysql' 카테고리의 다른 글
mysql5.5 넘어오면서 제거된 내용들 (0) | 2015.12.14 |
---|---|
mysql 기본 명령어 및 수정 (0) | 2015.12.11 |
mysql configure: error: Cannot find libmysqlclient_r under /usr/local/mysql. (0) | 2015.11.13 |
mysql 외부접근 허용 (0) | 2015.10.07 |
mysql 백업 및 복구 (0) | 2015.10.07 |