20172017. 7. 17. 10:30

CentOS Linux release 7.3 에서 Azure SQL DB 에 연결하는 간단한 방법입니다.

Azure Portal 을 통해서 CentOS 7.3 서버를 생성하고 기본적인 DB 연결 도구를 설치한 후 Azure SQL DB 에 연결하였습니다.

 

 

[root@centostest ~]# cat /etc/*-release
CentOS Linux release 7.3.1611 (Core)

 

 

아래 문서에서 볼 수 있듯이 ‘Install tools on RHEL’ 기준으로 sqlcmd command-line 툴을 리눅스에 설치합니다.

 

Install sqlcmd and bcp the SQL Server command-line tools on Linux
https://docs.microsoft.com/en-us/sql/linux/sql-server-linux-setup-tools

 

CentOS RPM 패키지 구성 상태에 따라 해당 문서 절차대로 진행해도 되고 아래와 같이 필요한 부분(패키지 설치와 경로 설정)만 적용할 수도 있습니다.

 

[root@centostest bin]# yum install mssql-tools unixODBC-devel
[root@centostest bin]# echo 'export PATH="$PATH:/opt/mssql-tools/bin"' >> ~/.bash_profile
[root@centostest bin]# echo 'export PATH="$PATH:/opt/mssql-tools/bin"' >> ~/.bashrc
[root@centostest bin]# source ~/.bashrc

 

 

설치가 완료된 후 sqlcmd 명령으로 Azure SQL DB 에 연결한 캡쳐 화면입니다.

# sqlcmd -Stcp:서버이름 -U 사용자 -P 패스워드

 

 

sqlcmd 를 사용하는 자세한 방법은 아래 링크를 참조하실 수 있습니다.

 

Connect to SQL Server on Linux and run Transact-SQL queries
https://docs.microsoft.com/en-us/sql/linux/sql-server-linux-connect-and-query-sqlcmd

 

작성자: Lai Go / 작성일자: 2017.07.17

 

Posted by Lai Go