MSSQL to deploy Linux,

red hat linux version of the series is mainly used, CentoS 7.X, MSSQL2017

Microsoft's official description Address: https://docs.microsoft.com/zh-cn/sql/linux/quickstart-install-connect-red-hat?view=sql-server-2017

According to the official description rapid installation linux version mssql, this version to maintain the basic functions of database schema, but no agency services, reporting services and other functions, the program is not very streamlined, very fitting features of linux.

Basic applications after installation of:

1. Database Connection Method

 sqlcmd -S localhost -U SA // -S connection address, -U login name

According to the then prompted for a password, appears> identifiers, to indicate successful landing, then you can start to write the sql statement operation

 

2. Restore the database approach

2.1 mssql database backup copy of the database directory to / var / opt / mssql / data /

2.2 file into the directory

cd /var/opt/mssql/data

2.3 logical name query bak files, log logical name

Query Analyzer run in mode (see first entering mode): the RESTORE FILELISTONLY the FROM DISK = '/ var / opt / MSSQL / Data / Test'  - input after the transport, will separate line, and then must enter the transport to go execute the statement (equivalent to the windows sql query analyzer to perform / F5 / CTRL + X)

Then that logical names and logical name logs were: test.mdf and test_log.ldf, remember these two names.

Database restore operation starts 2.3

The Test DATABASE RESTORE --test out to restore the database name

FROM DISK = '/var/opt/mssql/data/test' --备份文件路径

WITH MOVE 'test' TO '/var/opt/mssql/data/test.mdf', --前一个单引号中的是mdf逻辑名,注意大小写,不可写错,后一个单引号为还原目的地址,两句间有逗号

MOVE 'test_log' TO '/var/opt/mssql/data/test_log.ldf' --前一个单引号中的是ldf日志文件逻辑名,注意大小写,不可写错,后一个单引号为还原目的地址

GO

 

 还原成功后,如下图提示:

 

3. 简单的使用示例

3.1 按照第1点登陆数据库后,首先需要选择数据库

 3.2 然后开始写语句,写完语句需要执行,一定写go回车

大概记到这里。

 

Guess you like

Origin www.cnblogs.com/airlinp/p/12360838.html