本文指导你完成在CentOS 7/Fedora 29/Fedora 28系统上安装Microsoft SQL Server 2019的步骤。SQL Server从2017版开始在Linux上运行[Ubuntu下部署SQL Server 2017(安装及使用方法,卸载方法)],此SQL Server与在Microsoft操作系统上运行的SQL Server数据库引擎相同,具有许多类似的功能和服务。
步骤1:在CentOS 7/Fedora 29/28上安装Microsoft SQL Server 2019 Microsoft SQL Server 2019可从Preview(2019)存储库获得,通过在终端上运行以下命令,将存储库添加到CentOS 7/Fedora中: sudo curl -o /etc/yum.repos.d/mssql-server.repo https://packages.microsoft.com/config/rhel/7/mssql-server-preview.repo 这将把SQL Server 2019存储库下载到/etc/yum.repos.d/mssql-server.repo。 更新系统缓存: sudo yum makecache # CentOS 7 sudo dnf makecache # Fedora 然后安装SQL Server 2019: sudo yum install -y mssql-server 对于Fedora,运行以下命令: sudo dnf install -y mssql-server 要获取有关已安装软件包的信息,请运行: $ rpm -qi mssql-server
步骤2:初始化MS SQL数据库引擎 程序包安装完成后,运行mssql-conf setup并按照提示设置SA密码并选择版本: sudo /opt/mssql/bin/mssql-conf setup 1.选择要使用的版本 Choose an edition of SQL Server: 1) Evaluation (free, no production use rights, 180-day limit) 2) Developer (free, no production use rights) 3) Express (free) 4) Web (PAID) 5) Standard (PAID) 6) Enterprise (PAID) 7) Enterprise Core (PAID) 8) I bought a license through a retail sales channel and have a product key to enter. 我选择2,即开发人员(免费,没有生产使用权)。 2.接受许可条款 The license terms for this product can be found in /usr/share/doc/mssql-server Do you accept the license terms? [Yes/No]:Yes 3.设置SQL Server系统管理员密码 Enter the SQL Server system administrator password: <Password> Confirm the SQL Server system administrator password:<Confirm Password> Configuring SQL Server... sqlservr: This program requires a machine with at least 2000 megabytes of memory. /opt/mssql/bin/sqlservr: This program requires a machine with at least 2000 megabytes of memory. Initial setup of Microsoft SQL Server failed. Please consult the ERRORLOG in /var/opt/mssql/log for more information.
步骤3:启动并启用mssql-server服务 启动mssql-server服务: sudo systemctl start mssql-server 启用它以在系统引导时启动 sudo systemctl enable mssql-server 将/opt/mssql/bin/添加到$PATH变量: echo 'export PATH=$PATH:/opt/mssql/bin' | sudo tee /etc/profile.d/mssql.sh 源文件以在当前shell会话中开始使用MSSQL可执行二进制文件: source /etc/profile.d/mssql.sh 如果有活动的Firewalld服务,请允许远程主机的SQL Server端口连接: sudo firewall-cmd --add-port=1433/tcp --permanent sudo firewall-cmd --reload
步骤4:测试SQL Server 连接到SQL Server并验证它是否正常工作: $ sqlcmd -S localhost -U SA 使用步骤2中设置的密码进行身份验证。 显示数据库用户: 1> select name from sysusers; 2> go 创建测试数据库: CREATE DATABASE testDB SELECT Name from sys.Databases GO USE testDB CREATE TABLE Inventory (id INT, name NVARCHAR(50), quantity INT) INSERT INTO Inventory VALUES (1, 'banana', 150); INSERT INTO Inventory VALUES (2, 'orange', 154); GO SELECT * FROM Inventory LIMIT 1; 在SQL Server上显示数据库:
删除数据库: 1> drop database testDB; 2> go 至此,测试SQL Server内容结束。
相关主题 |