. NET Core Development Log--linux version of SQL Server

Source: Internet
Author: User
Tags management studio sql server management sql server management studio docker ps docker run

The SQL Server 2017 version can already be installed on Linux systems, but I'm using a Mac system when I try. NET Core cross-platform development, so here's the process of installing SQL Server on your Mac.

The latest SQL Server does not specifically prepare the installation package for Mac systems, but because Docker is supported on Mac systems, you can use a workaround-install the Linux version of SQL Server inside Docker.

System Requirements

Because my MacBook Air model is older and the hardware conditions are very general, first determine if the conditions for installing SQL Server are met. The official configuration is as follows:

Memory 2 GB
File system XFS or EXT4 (other file systems, such as BTRFS, is unsupported)
Disk space 6 GB
Processor speed 2 GHz
Number of processor cores 2 cores
Processor type X64-compatible only

The request is not high, there seems to be no problem.

Docker application

The Mac version of Docker can be downloaded from the following address:
Docker Community Edition for Mac
You can also use commands to verify the results after you complete the installation docker -v .

Docker image

With the Docker program, the first thing to do is pull the SQL Server image for the Linux system.

docker pull microsoft/mssql-server-linux:2017-latest
Docker container

The container is then started through the pulled image

docker run -d --name macsqlserver -e 'ACCEPT_EULA=Y' -e 'SA_PASSWORD=Passw1rd' -e 'MSSQL_PID=Developer' -p 1433:1433 microsoft/mssql-server-linux:2017-latest

The parameters used in this command have a practical purpose:
-D runs the container in daemon mode, that is, the application that is started runs in the background
--name assigning a name to a container
-E ' accept_eula=y ' sets environment variables inside the container to confirm acceptance of the End User License Agreement--end-user License Agreement (EULA)
-E ' sa_password=passw1rd ' sets the password for SA account inside the container
-E ' Mssql_pid=developer ' is also an environment variable that allows SQL Server to run as a developer version
-P 1433:1433 Map local 1433 port to container internal SQL Server 1433 port

After executing the above command, docker ps -a you can view the status of the Started container. If the status is up, the container is running correctly.

SQL Server Client

Because SQL Server Management Studio is not ported to other systems, it is necessary to use a third-party tool to connect the installed SQL Server as a client to the MAC system. SQL-CLI is one of the clients developed with Nodejs.

First install the SQL-CLI in NPM mode.

npm install -g sql-cli

After the installation is completed to enter the command (the password entered must match the actual setting):

mssql -u sa -p Passw1rd

If the connection is successful, .databases you can then enter the command to see the familiar SQL Server four databases.

Visual Studio Code Plug-in

One of the great benefits of using VSC is that it contains rich plugins. For example, after installing MSSQL this plugin, you can use the convenience of VSC, the development of SQL program.

To give a simple example:
⌘N, create a new file
⌘k M, change the language mode to SQL
⇧⌘p, open the Command box, enter SQL, select MS SQL: Connect , select Create Connection Profile , and then enter a list of database connection configurations.
If you finally see something like the following in the lower right corner of the VSC, you have successfully connected to the database.

Next, enter the SQL statement inside the file

use masterselect * from spt_monitor

⇧⌘e, execute the above statement. You can see the results in a new window.

It is worth mentioning that in the results window, you can also save records as a file.

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.