1、升级系统
yum update -y
2、安装yum-utils包
yum install -y yum-utils
3、增加数据库的yum仓库
yum-config-manager --add-repo https://packages.microsoft.com/config/rhel/7/mssql-server-2019.repo
4、安装sqlserver
yum install -y mssql-server
/opt/mssql/bin/mssql-conf setup
输入数字3。后面一路y,需要记住设置的sa密码。
5、启动服务
systemctl start mssql-server
ss -tnl
6、安装unixodbc
yum-config-manager --add-repo https://packages.microsoft.com/config/rhel/7/prod.repo
yum install -y mssql-tools unixODBC-devel
ln -s /opt/mssql-tools/bin/sqlcmd /usr/bin
sqlcmd -S localhost -U sa
#查看sqlserver的状态
systemctl status mssql-server
#停止sqlserver服务
systemctl stop mssql-server
#开启sqlserver服务
systemctl Start mssql-server
#停止并且禁止sqlserver自启动
systemctl stop mssql-server
systemctl disable mssql-server
#设置开机自启并启动sqlserver
systemctl enable mssql-server
systemctl start mssql-server
关闭系统密码登录,启用秘钥登录。
#导入用户的公钥
cd ~/.ssh
cat id_ras.pub >>authorized_keys
vi /etc/ssh/sshd_config
#增加:
RSAAuthentication yes
PubkeyAuthentication yes
AuthorizedKeysFile .ssh/authorized_keys
PasswordAuthentication no
systemctl restart sshd.service