[펌글] mysql에 root권한으로 접근을 해도 접근거부가 될 경우

By | 1월 3, 2011

- 출처 : http://greenalice.tistory.com/25 -

설치시 에러 나타날때
[qtam@localhost qtam]$ mysql -u root mysql     
ERROR 1045: Access denied for user: 'root@localhost' (Using password: NO)

1. -h (호스트) 적용
2. mysql killall safe_mysqld --user=mysql --skip-grant-table &
3.

MySQL 을 처음 설치한 후 아무런 변경도 하지 않는 경우에는 root 사용자의 암호가 설정되
어 있지 않습니다. 따라서 MySQL 을 처음 설치한 경우에는 다음과 같은 명령으로 MySQL
서버에 연결을 할 수 있습니다.
[wertyu@inos ~]$ mysql -u root mysql

여기서 주의할 점은 mysql 은 -u 옵션으로 사용자 명을 주지 않는 경우 시스템 계정 사용자
의 이름을 이용한다는 것입니다.
[wertyu@inos ~]$ mysql mysql
ERROR 1045: Access denied for user: 'wertyu@localhost' (Using password: NO)

만약 mysql 을 사용하면서 다음과 같은 에러가 발생한다면 사용자에게 암호가 걸려 있는 것
입니다.
[wertyu@inos ~]$ mysql -uroot mysql
ERROR 1045: Access denied for user: 'root@localhost' (Using password: NO)

- mysql root 비밀번호 잊어 먹었을 때
[root@localhost local]# killall mysqld

//권한없이 접속가능하도록하는옵션입니다.
[root@localhost local]# /usr/local/mysql/bin/mysqld_safe --skip-grant-tables &

//mysql로 접속합니다.
[root@localhost local]# mysql
Welcome to the MySQL monitor.  Commands end with ; or g.
Your MySQL connection id is 2 to server version: 4.0.20-log

//비밀번호를 변경합니다.
Type 'help;' or 'h' for help. Type 'c' to clear the buffer.
mysql> use mysql
Database changed
mysql> update user set password=password('비밀번호') where  user='root';
Query OK, 2 rows affected (0.02 sec)
Rows matched: 2  Changed: 2  Warnings: 0

mysql> exit
Bye

//mysql을 중지시키고 다시 스타트합니다.
[root@localhost local]# killall mysqld
[root@localhost local]# /usr/local/mysql/bin/mysqld_safe &

Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments