본문 바로가기

DB/MySQL

MySQL 접근 시 Access denied for user 'root'@'localhost' 해결 방법

# sudo mysql -u root -p 를 입력하면, 관리자 권한으로 실행하고, root 패스워드와 mysql 사용자 패스워드를 물어본다.
2개다 올바르게 입력하면 정상적으로 mysql로 접근 할 수 있다.

monitoring-server@monitoringserver-Virtual-Machine:/$ mysql -u root -p
Enter password:
ERROR 1698 (28000): Access denied for user 'root'@'localhost'

monitoring-server@monitoringserver-Virtual-Machine:/$ sudo mysql -u root -p
[sudo] monitoring-server의 암호:
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 95
Server version: 5.7.36-0ubuntu0.18.04.1 (Ubuntu)

Copyright (c) 2000, 2021, Oracle and/or its affiliates.

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> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| sys                |
| zabbix             |
+--------------------+
5 rows in set (0.07 sec)

- 끝 -

'DB > MySQL' 카테고리의 다른 글

MySQL 테이블의 데이터를 CSV 파일로 내보내는 4가지 방법  (0) 2022.01.27
MySQL Timeout 설정  (0) 2021.02.23