Bite Bits/Raspberry Pi

raspbian jessi 에서 mariadb 원격접속 설정하기

상영 2017. 12. 6. 11:44

raspbian 에 설치된  mariadb 를 내 pc 에서 관리, 이용하기 위해서 설정 시작.


mariadb 설치 과정은 여기 => http://blog.daum.net/to302/64


우선 내 PC (windows) 에서 사용할 client 프로그램 HeidiSQL 설치 => https://www.heidisql.com


raspbian 에 설치된 mariadb 접속


$ mysql -u root -p


내 PC 의 IP 에서 root 계정으로 접근할 때 전체 권한을 가지도록 설정.

MariaDB [(none)]> GRANT ALL PRIVILEGES on *.* TO 'root'@'192.168.20.2' IDENTIFIED BY '암호' WITH GRANT OPTION; 

MariaDB [(none)]> FLUSH PRIVILEGES;


외부 IP 에서 접속을 허용하기 위해선 /etc/mysql/my.cnf  파일에서

bind-address = 127.0.0.1 로 된 부분을 찾아서

bind-address = 0.0.0.0 으로 수정


Character-set 설정관련은 /etc/mysql/my.cnf 젤 아래에 !includedir /etc/mysql/conf.d/ 라고 된 부분이 있는데,

이 디렉토리를 가보면 아래의 파일이 있다.

/etc/mysql/conf.d/mariadb.cnf 

이 파일을 열어보면 default-character-set 에 대한 부분이 주석처리되어 있는데,

기본 설정은 Latin1 이니 필요하면 주석을 풀어서 사용하라는 언급이 되어 있다.

필요하다면 풀어서 사용할 것 .. 


pi@raspberrypi:/etc/mysql/conf.d $ more mariadb.cnf 

# MariaDB-specific config file.

# Read by /etc/mysql/my.cnf


[client]

# Default is Latin1, if you need UTF-8 set this (also in server section)

#default-character-set = utf8 


[mysqld]

#

# * Character sets

# Default is Latin1, if you need UTF-8 set all this (also in client section)

#

#character-set-server  = utf8 

#collation-server      = utf8_general_ci 

#character_set_server   = utf8 

#collation_server       = utf8_general_ci 


설정파일이 변경되었다면, 

$ sudo service mysql restart 

혹은

$ sudo /etc/init.d/mysql restart

하여 서버 재시작 



* 추가

iptables 같은 방화벽 설정을 했다면, 그 부분도 같이 봐줘야 하지만, 난 그런거 없으므로 여기까지만..



* 참고 : 

- MariaDB(MySQL) 원격에서 접근이 가능하도록 설정하기, http://gafani.tistory.com/entry/MariaDBMySQL-원격에서-접근이-가능하도록-설정하기

- mariadb 설치, http://seodaeya.tistory.com/entry/Maria-DB-설치-in-Raspberry-Pi

- [R.Pi + Linux] Raspberry Pi3 HeidiSQL 접속 설정하기(DB 외부 접속), http://freehoon.tistory.com/53