1. 安装SQL Server
(1)下载 Microsoft SQL Server Red Hat 存储库配置文件
sudo curl -o /etc/yum.repos.d/mssql-server.repo https://packages.microsoft.com/config/rhel/7/mssql-server-2017.repo
(2)安装 SQL Server
sudo yum install -y mssql-server
(3)运行mssql conf 安装命令进行配置
密码设置:sqlserver@123
sudo /opt/mssql/bin/mssql-conf setup
(4)验证服务是否启动了
- 两种查询方式
systemctl status mssql-server
ps -ef | grep mssql
(5)设置防火墙
sudo firewall-cmd --zone=public --add-port=1433/tcp --permanent
sudo firewall-cmd --reload
2. 连接SQL Server
(1)下载客户端工具的源、安装客户端工具
sudo curl -o /etc/yum.repos.d/msprod.repo https://packages.microsoft.com/config/rhel/7/prod.repo
sudo yum install -y mssql-tools
(2)配置环境变量
echo 'export PATH="$PATH:/opt/mssql-tools/bin"' >> ~/.shell_profile
echo 'export PATH="$PATH:/opt/mssql-tools/bin"' >> ~/.shellrc
source ~/.shell_profile
source ~/.shellrc
(3)连接sql sever
sqlcmd -S localhost -U SA -P 'sqlserver@123'