투덜이 개발자

Ubuntu(우분투) MariaDB [mysql] root 비밀번호를 변경 했는데 비밀번호 입력하지 않고 로그인 되는게 정상? 본문

DataBase/MySQL

Ubuntu(우분투) MariaDB [mysql] root 비밀번호를 변경 했는데 비밀번호 입력하지 않고 로그인 되는게 정상?

엠투 2024. 1. 17. 13:31
반응형

우분투 에 Mariadb 를 설치하고 비밀번호를 변경하였지만 비밀번호 없이 로그인이 된다.

set password for 'root'@'localhost' = password('1234');
flush privileges;

 

위와 같이 비밀번호를 설정하였지만 비밀번호 없이 로그인이 된다..

root@hosting:~# mysql
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 2124
Server version: 10.6.12-MariaDB-0ubuntu0.22.04.1 Ubuntu 22.04

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [(none)]>

이는 auth_socket 플러그인을 사용하여 비밀번호 없이 로그인 하게 된다.

 

 

SHOW GRANTS FOR 'root'@'localhost';

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]> SHOW GRANTS FOR 'root'@'localhost';
+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Grants for root@localhost                                                                                                                                                 |
+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| GRANT ALL PRIVILEGES ON *.* TO `root`@`localhost` IDENTIFIED VIA mysql_native_password USING '*2E68CF27ED293913CD03C7B0882AA7EA920C4827' OR unix_socket WITH GRANT OPTION |
| GRANT PROXY ON ''@'%' TO 'root'@'localhost' WITH GRANT OPTION                                                                                                             |
+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
2 rows in set (0.000 sec)

 

위와가팅 루트 사용자가 Unix 소켓 자격 증명에 의해 자동으로 인증됨을 의미합니다. 
이를 원하지 않으면 이전 명령을 무시하는 수동 GRANT 명령을 실행할 수 있습니다.

MariaDB [mysql]> GRANT ALL PRIVILEGES ON *.* TO 'root'@'localhost' IDENTIFIED BY 'mysecurepassword' WITH GRANT OPTION;
Query OK, 0 rows affected (0.001 sec)

MariaDB [mysql]> SHOW GRANTS FOR 'root'@'localhost';
+----------------------------------------------------------------------------------------------------------------------------------------+
| Grants for root@localhost                                                                                                              |
+----------------------------------------------------------------------------------------------------------------------------------------+
| GRANT ALL PRIVILEGES ON *.* TO `root`@`localhost` IDENTIFIED BY PASSWORD '*1EC3D76476758BC5486D23BF46F22E3FCDB19B1B' WITH GRANT OPTION |
| GRANT PROXY ON ''@'%' TO 'root'@'localhost' WITH GRANT OPTION                                                                          |
+----------------------------------------------------------------------------------------------------------------------------------------+
2 rows in set (0.000 sec)

이제 mysql은 비밀번호를 묻지만 유닉스 소켓에 액세스할 수 있는 모든 사용자가 사용할 수 있습니다(따라서 기본적으로 mysql -u root -p루트가 아니더라도 비밀번호를 알고 있으면 사용하면 됩니다).

 

https://serverfault.com/questions/912941/is-it-normal-that-one-can-access-mysql-as-root-without-entering-password-althou

 

Is it normal that one can access MySQL as root without entering password, although password is set?

I just installed MySQL (Ver 14.14 Distrib 5.7.22) on Ubuntu 18.04 and I discovered something weird: I installed MySQL and used mysql_secure_installation to set a password for root, but as soon as ...

serverfault.com

 

반응형