티스토리 뷰

Database

로컬 PC에서 MySQL 접속이 되지 않을때

파란크리스마스 2014. 1. 21. 15:55
728x90

출처 : 리눅스 종류 확인, 리눅스 버전 확인
MySQL: "ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)"

리눅스버전확인

[root@testserver init.d]# cat /etc/issue
CentOS release 5.9 (Final)
Kernel \r on an \m

로컬 PC에서 접속이 되지 않을때

ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)

MySQL 서비스 종료

[root@testserver init.d]# service mysqld stop
mysqld 를 정지 중:                                         [  OK  ]

권한 테이블 없이 MySQL 실행하기

[root@testserver init.d]# mysqld_safe --skip-grant-tables &
[1] 4712
[root@testserver init.d]# Starting mysqld daemon with databases from /var/lib/mysql

MySQL 접속

[root@testserver init.d]# mysql
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.0.95 Source distribution

Copyright (c) 2000, 2011, 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> 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

기존 root@localhost 사용자가 존재하고 있으면 패스워드만 변경 (패스워드만 분실했을 경우)

mysql> update user set `Password`=PASSWORD('root12');
Query OK, 6 rows affected (0.00 sec)
Rows matched: 6  Changed: 6  Warnings: 0

사용자 추가 (권한 변경은 MySQL 재시작후 실행)

mysql> INSERT INTO `user` (`host`, `user`, `password`) VALUES('localhost','root',PASSWORD('root12'));
Query OK, 1 row affected, 3 warnings (0.01 sec)

mysql> grant all privileges on *.* to 'root'@'localhost';
Query OK, 0 rows affected (0.00 sec)

MySQL 반영 (내장 캐쉬를 소거)

mysql> flush tables;
Query OK, 0 rows affected (0.00 sec)
mysql> quit
Bye

MySQL 서비스 다시 종료

[root@testserver init.d]# /etc/init.d/mysqld stop
STOPPING server from pid file /var/run/mysqld/mysqld.pid
140121 16:02:23  mysqld ended

mysqld 를 정지 중:                                         [  OK  ]
[1]+  Done                    mysqld_safe --skip-grant-tables

MySQL 서비스 시작

[root@testserver init.d]# /etc/init.d/mysqld start
mysqld (을)를 시작 중:                                     [  OK  ]

댓글
300x250
공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
«   2024/04   »
1 2 3 4 5 6
7 8 9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28 29 30
글 보관함