develog

[mariaDB] 외부에서 접속 안될 때 본문

카테고리 없음

[mariaDB] 외부에서 접속 안될 때

냐옴 2024. 3. 8. 13:19

 

ubuntu 에 mariaDB 설치하기
$ sudo apt install mariadb-server
$ sudo apt install mariadb-client

 

bind-address 를 0.0.0.0 으로 수정한다

 

bind-address 를 0.0.0.0 으로 수정한다

## sudo vi /etc/mysql/mariadb.conf.d/50-server.cnf

# Instead of skip-networking the default is now to listen only on
# localhost which is more compatible and is not less secure.
#bind-address            = 127.0.0.1
bind-address            = 0.0.0.0

 

mariaDB 를 재시작한다

systemctl restart mariadb

 

root 계정의 host 를 % 로 변경한다

 

mariaDB 에 접속한다

root@ubuntu01:~# mysql -u root
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 42
Server version: 10.6.16-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)]>

 

DB 를 mysql 로 변경한다

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]>

 

root 계정의 host 를 확인한다

MariaDB [mysql]> select host, user, password from user;
+-----------+-------------+----------+
| Host      | User        | Password |
+-----------+-------------+----------+
| localhost | mariadb.sys |          |
| localhost | root        | invalid  |
| localhost | mysql       | invalid  |
+-----------+-------------+----------+
3 rows in set (0.001 sec)

 

root 계정의 host 를 % 로 등록한다

MariaDB [mysql]> grant all privileges on *.* to 'root'@'%' identified by '111111';
Query OK, 0 rows affected (0.014 sec)

MariaDB [mysql]>

 

등록됐는지 확인한다

MariaDB [mysql]> select host, user, password from user;
+-----------+-------------+-------------------------------------------+
| Host      | User        | Password                                  |
+-----------+-------------+-------------------------------------------+
| localhost | mariadb.sys |                                           |
| localhost | root        | invalid                                   |
| localhost | mysql       | invalid                                   |
| %         | root        | *FD571203974BA9AFE270FE62151AE967ECA5E0AA |
+-----------+-------------+-------------------------------------------+
4 rows in set (0.001 sec)

MariaDB [mysql]>

 

외부에서 DB 접속이 되는지 확인한다

 

Comments