Installing SQL Server under Linux

Source: Internet
Author: User
Tags mssql

I'm using CENTOS7 to complete the test in the virtual machine.

1, download set MSSQL Yum Source, execute the following code, now SQL Server Linux version 130 trillion, slow speed please wait

Curl Https://packages.microsoft.com/config/rhel/7/mssql-server.repo >/etc/yum.repos.d/mssql-server.reposudo Yum Install-y mssql-server

2, run the first Setup command, set the password, if your memory is less than 3G, this step will not pass, if you build with virtual machine, please note

/opt/mssql/bin/sqlservr-setup

3. Shut down the firewall or allow fire-resistant 1433 ports

Systemctl Stop Firewalld

Now that SQL Server is installed, if none of the above code execution errors occur, you can connect the test under Windows with SQL Servers Managerment Studio

4, because the Linux and Windows system drive letter path format is not the same, if you use SQL Server graphical management tool to create a new database, I here the database is created by default to the/var/opt/mssql/data/directory, I want to create a new database to/var/mymssql, but by default the SQL Server service does not have permission to manipulate this folder, you need to modify the permissions of this folder

Mkdir/var/mymssqlchown Mssql:mssql/var/mymssql

5, then create the database, note here the path format, usually express Linux file/var/testdb.mdf So, here to create to use the C + + start and/left slash to change \ Right slash

Create database TestDB on  primary (    name= ' TestDB ',     filename= N ' C:\var\testdb.mdf ',     SIZE=5MB,     MAXSIZE=100MB,    filegrowth=15%) Log on (    name= ' Testdb_log ',    filename=n ' c:\var\stuDB_log.ldf ',    SIZE=2MB,    FILEGROWTH=1MB)

6, modify the database default collation, otherwise the database Chinese will be garbled, the implementation of this step, the database is just created, otherwise cannot be executed through

7. Build table and test

CREATE TABLE classtable (ID int primary key identity () not null,classname nvarchar (max)) Goinsert into classtable values ( ' Class 1 ') insert into classtable values (' Class 2 ') gocreate table usertable (ID int primary key identity () not NULL, name nvarcha R (max) not null,sex bit, ClassID int. FOREIGN key references classtable (ID)) Goinsert into usertable values (' Student 1 ', 1, 1) in SERT into usertable values (' Student 2 ', 1, 2) SELECT * FROM Classtableselect * from usertable

End!

Installing SQL Server under Linux

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.