티스토리 뷰

반응형

우분투나 라즈베리파이에 MySQL이 쓸 일이 있어 mysql 명령어를 실행했다.

ubuntu@test:~$ mysql -u root -p

보통 위와 같이 실행한다.

그리고 root 비밀번호를 입력했으나 access denied가 뜬다.

ubuntu@test:~$ mysql -u root -p
Enter password: 
ERROR 1698 (28000): Access denied for user 'root'@'localhost'

대부분 update user 명령어를 사용해서 해결 가능하다고 했으나 해결이 안되어 방법을 찾아보니...

MariaDB [(none)]> 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
MariaDB [mysql]> update user set password=password('testpassword') where user='root';
Query OK, 1 row affected (0.00 sec)
Rows matched: 1  Changed: 1  Warnings: 0

MariaDB [mysql]> grant all on *.* to 'root'@'localhost' identified by 'testpassword' with grant option;
Query OK, 0 rows affected (0.00 sec)

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

MariaDB [mysql]> commit;
Query OK, 0 rows affected (0.00 sec)

grant all 명령어를 빼먹고 commit 도 안하는분들이 많다... 위와 같이 입력하면 입력한 비밀번호로 root의 비밀번호가 변경된다.

그러면 sudo 를 입력하지 않고 mysql -u root -p 명령어로도 로그인이 가능하다.

끄-읏

반응형
반응형
공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
링크
«   2024/05   »
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 31
글 보관함