天天看點

linux下安裝sql server

以Centos 7系統為例:

[root@c7 ~]# cat /etc/redhat-release              #系統版本

CentOS Linux release 7.1.1503 (Core) 

[root@c7 ~]# firewall-cmd --state                 #檢視firewall狀态,關閉firewall

running

[root@c7 ~]# systemctl stop firewalld.service     #關閉

[root@c7 ~]# systemctl disable firewalld.service  #開機不啟動

rm '/etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service'

rm '/etc/systemd/system/basic.target.wants/firewalld.service'

[root@c7 ~]# firewall-cmd --state                 #已關閉firewall

not running

[root@c7 yum.repos.d]# pwd                        #進入/etc/yum.repos.d下載下傳二個yum源檔案

/etc/yum.repos.d

[root@c7 yum.repos.d]# wget https://packages.microsoft.com/config/rhel/7/mssql-server.repo

[root@c7 yum.repos.d]# wget https://packages.microsoft.com/config/rhel/7/prod.repo

[root@c7 yum.repos.d]# yum search mssql           #檢視源資訊,已有包資訊

mssql-server.x86_64 : Microsoft(R) SQL Server(R) Relational Database Engine

mssql-server-ha.x86_64 : Microsoft(R) SQL Server(R) Relational Database Engine

mssql-tools.x86_64 : Tools for Microsoft(R) SQL Server (R)

....略

[root@c7 yum.repos.d]# yum install -y mssql-server mssql-tools    #安裝服務和工具

...略

已安裝:

  mssql-server.x86_64 0:14.0.1.246-6

  mssql-tools.x86_64 0:14.0.1.246-1 

[root@c7 ~]# cd /opt/mssql/bin/                   #進入sql目錄

[root@c7 bin]# ls                                 #下面有啟動的檔案

compress-dump.sh  generate-core.sh  mssql-conf  sqlpackage  sqlservr  sqlservr-setup  sqlservr-telemetry

[root@c7 bin]# ./sqlservr-setup                   #執行此檔案,依照提示設定密碼等資訊

Microsoft(R) SQL Server(R) Setup

You can abort setup at anytime by pressing Ctrl-C. Start this program

with the --help option for information about running it in unattended

mode.

Please enter a password for the system administrator (SA) account:         設定密碼

Please confirm the password for the system administrator (SA) account:     确認密碼

Setting system administrator (SA) account password...

Do you wish to start the SQL Server service now? [y/n]: y                   開啟服務

Do you wish to enable SQL Server to start on boot? [y/n]: y                 開機啟動服務

ln -s '/usr/lib/systemd/system/mssql-server.service' '/etc/systemd/system/multi-user.target.wants/mssql-server.service'

ln -s '/usr/lib/systemd/system/mssql-server-telemetry.service' '/etc/systemd/system/multi-user.target.wants/mssql-server-telemetry.service'

Setup completed successfully.

[root@c7 bin]# systemctl status mssql

mssql.service

   Loaded: not-found (Reason: No such file or directory)

   Active: inactive (dead)

[root@c7 ~]# sqlcmd -S localhost -U sa

Password: 

1> select db_name();

2> go

--------------------------------------------------------------------------------------------------------------------------------

master  

    檢視使用CPU和記憶體高的程序

# ps -eo pid,ppid,cmd,%mem,%cpu --sort=-%mem | head

<a href="http://s3.51cto.com/wyfs02/M00/8A/FE/wKioL1hBF7exJXTKAACseqfCR4A730.jpg" target="_blank"></a>

    使用SQL Management連接配接資料庫

伺服器IP

[root@c7 ~]# hostname -I

192.168.2.117

參考自:

<a href="https://docs.microsoft.com/zh-cn/sql/linux/sql-server-linux-setup-red-hat" target="_blank">https://docs.microsoft.com/zh-cn/sql/linux/sql-server-linux-setup-red-hat</a>

<a href="http://www.cnblogs.com/hengwei/p/6076199.html" target="_blank">http://www.cnblogs.com/hengwei/p/6076199.html</a>

      本文轉自cix123  51CTO部落格,原文連結:http://blog.51cto.com/zhaodongwei/1878802,如需轉載請自行聯系原作者