본문 바로가기

리눅스

[리눅스] MySQL 5.7 이후 버전 root 비밀번호 변경

728x90

MySQL(5.7.19 이후 버전) 설치 후 아래와 같은 에러가 발생

ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.

아래 명령으로 패스워드를 변경할 수 있다.

SET PASSWORD = PASSWORD('P@ssw0rd1!');

 

./mysql -uroot -p
$ ./mysql -uroot -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 6
Server version: 5.7.19

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

 

show databases;
mysql> show databases;
ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.
728x90

 

SET PASSWORD = PASSWORD('P@ssw0rd1!');
mysql> SET PASSWORD = PASSWORD('P@ssw0rd1!');
Query OK, 0 rows affected, 1 warning (0.01 sec)

 

select 1;
mysql> select 1;
+---+
| 1 |
+---+
| 1 |
+---+
1 row in set (0.00 sec)
mysql> FLUSH privileges;
Query OK, 0 rows affected (0.00 sec)

 

show databases;
mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| sys                |
+--------------------+
4 rows in set (0.00 sec)
mysql> exit
Bye

 

728x90