콘솔에서 root로 접속하려고 할 때 아래와 같은 에러 메시지가 뜨는 경우가 있다.

[root@nyaongnyaong ~] # mysql -uroot -p

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

이런 경우는 위 에러 메시지를 긁어서 네이버나 구글에서 검색해 보는 게 가장 빠르다.

[root@nyaongnyaong ~]# mysql
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 4008
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

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
mysql> grant all on *.* to 'root'@'localhost' identified by '비밀번호' with grant option;
Query OK, 0 rows affected (0.00 sec)

mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)

mysql> exit

이렇게 하믄 끝