Selasa, 05 Juli 2022

MSSQL SERVER-setup&create user

 

How to Install MS SQL Server 2019 Express Edition on Windows Server 2016/19?

https://www.e2enetworks.com/blog/how-to-install-ms-sql-server-2019-express-edition-on-windows-server-2016-19

MS SQL Express edition is the entry-level, free database and is ideal for learning and building desktop and small server data-driven applications. It is the best choice for independent software vendors, developers, and hobbyists building client applications. If you need more advanced database features, SQL Server Express can be seamlessly upgraded to other higher-end versions of SQL Server. SQL Server Express LocalDB is a lightweight version of Express that has all of its programmability features, runs in user mode and has a fast, zero-configuration installation and a shortlist of prerequisites.

This article will guide you on how to perform a new SQL Server 2019 Express Edition installation on a Windows host using the Installation Wizard.

MS SQL Server 2019 Express Edition can be downloaded from the below mentioned web link

https://www.microsoft.com/en-us/sql-server/sql-server-downloads

The following are some recommendations before installing SQL Server 2019:

1. Windows Server 2016/19 with latest patch levels should be installed prior to Installation or Windows host should be installed with the latest windows update.

2. SQL Server Management Studio (SSMS) is recommended.

3. Installing SQL Server 2019 express requires .NET Framework 4.6 be installed. You can check before the install but it will check and install it automatically if needed. If you are using Windows Server 2012 R2, update KB2919355 is required before installing the framework.

4. It is not supported to install SQL Server 2019 Express Edition through the Terminal Services client.

Step-by-step procedure to install SQL Server 2019 Express Edition

  1. Navigate to downloaded “SQL2019-SSEI-Expr.exe” file and double click on it for installation and choose your installation type

Note : You can stick with Basic unless you have custom options and location you’d like to set.

SQL Server 2019 Express Edition Installation Type :-

1. Basic Type will install default packages by downloading from the internet.  In this blog we will use this installation type.

2. Custom Type provides customization features of MS SQL 2019 Express where we can install extra features of MS SQL or remote some default features.

3. Download Media Type will only download setup files from the internet and do not start the installation. This can be useful if we do not have an internet connection and install MS SQL on your machine later.

3. Accept the license agreement

4. Choose a default Install Location or other Install Location then you can select Install

5. Completed Successfully! From here you can Connect to the server immediately, or Customize the installation, and Install SQL Server Management Studio(SSMS).

SQL Server Management Studio (SSMS) installation 

1. You can click on Install SSMS or download SSMS via below mentioned web link

SSMS Download Link - https://docs.microsoft.com/en-us/sql/ssms/download-sql-server-management-studio-ssms?view=sql-server-ver15

2. Click on Download SSMS and save it.

3. After Download SSMS .exe file, click on it and Install it.

4. After the finish installation, Restart server.

5. Finally SQL Server Management Studio (SSMS) is installed on your Server.

How to connect MS SQL 2019 Express Edition to SQL Server Management Studio (SSMS)

1. Click on Windows Home and search “SQL Server Management Studio” and click to start SSMS

2. Click on connect to connect your MS SQL 2019 Express Database via Windows Authentication

3. From here, You can Manage your MS SQL Database.

======================================================

Enable SA User

======================================================

How to enable sa Account in SQL Server?

83 Votes


When you install the SQL Server using Windows Authentication mode, by default, the “sa” account is disabled. Sometimes, due to users/customers request, you may need to enable the sa account. You need to change the authentication mode for SQL server from Windows Authentication Mode to SQL Server and Windows Authentication Mode to use the sa account.

To Change the Authentication Mode:

Follow the steps mentioned below to change the authentication mode from Windows Authentication to SQL Server and Windows Authentication. You need to remember that, the SQL Server service needs to restart to make this change effective.

1. Login to the SQL server instance using SQL Server Management Studio. Right-click on the database instance, and go to Properties.

image

2. On the Server Properties page, Click on Security. Click on the radio button next to SQL Server and Windows Authentication mode, and click on OK to close the  Server Properties page.

image

3. Once you clicked on the Ok button, we will get the following screen:

image

As discussed earlier, we need to restart the SQL Server service to make this change effective. After restarting the SQL Server, the authentication mode will be changed to SQL Server and Windows Authentication mode.

Enable the sa Login:

1. Connect to the SQL Server instance using SSMS and go to Security. Expand Security, go to Logins.

2.  You can see the sa account is disabled when you install SQL Server using Windows Authentication mode.

image

3. Right-click on the sa account and go to Login Properties. Specify a complex password for the sa account. By default, the Enforce password policy is checked. (if you don’t want to provide a complex password for the sa account, you can uncheck this option. However, this is not recommended.)

image

4. Click on the Status page. By default, the sa account will be disabled. Click on the Enabled button to enable the sa account. Click on Ok to close the sa Login Properties.

image

Thus, sa account is enabled and you will be able to login to the SQL instance using the sa account.

If you want to use a script to enable the sa account, you can use the script mentioned below:

1: USE [master]
2: GO
3: ALTER LOGIN [sa] WITH PASSWORD=N'z43VGYT@Iu*60i'
4: GO
5: ALTER LOGIN [sa] ENABLE
6: GO
========================================================================
CREATE User baru
========================================================================

Create a New User in SQL Server

Managing SQL Server security is a critical part of maintaining your SQL Server environment. In this article, let us take a step-by-step approach to create a new database User and grant permissions to the User.

In SQL Server, a Login is created for the server instance whereas a User is created for a database. A Login has to be mapped to a User to connect to a database. A login can be mapped to only one user for any database. The scope of a User is the database

There are two ways to create a new User or to grant user permissions:

  • Using Microsoft SQL Server Management Studio
  • Using T-SQL

Create New User using SSMS

Open SQL Server management studio. In the Object Explorer, expand the Databases node.

Here, we are going to create a new user for the HR database. So, expand the HR database.

Expand the Security folder of the database and right click on User and select New User, as shown below.

Create a New User and Grant Permissions in SQL Server 2019
176.7K
Too old to learn programming? at 30? Or 40 or 50? No. But...

In the Database User - New dialog box, on the General tab page, User type drop down lists the following types:

  • SQL user with login
  • SQL user with password
  • SQL user without login
  • User mapped to a certificate
  • User mapped to an asymmetric key
  • Windows user

Select the User type as "SQL User with login" from the drop-down.

Under User name, enter a new user name. Here, we will enter ‘Steve' as a user name.

Create a New User and Grant Permissions in SQL Server 2019

Under Login name, type the previously created login i.e., Steve. Alternately click on the ellipsis ... button to open the Select – Login dialog box.

Create a New User and Grant Permissions in SQL Server 2019

Click on Browse button and select an existing login name to map with this user, as shown below. Select login ‘Steve'. Click the OK button to proceed.

Create a New User and Grant Permissions in SQL Server 2019

The Owned Schema page lists all the available schemas in the database. To add schemas to the user, select the check box next to the schema name.

Create a New User and Grant Permissions in SQL Server 2019

The Membership page lists all the possible membership roles that can be owned by the database user being created. To add membership roles, select the check-box next to the roles.

Create a New User and Grant Permissions in SQL Server 2019

The Securables page lists all the securables and permissions that can be granted to the user. We will look at how to grant permissions to the User later in the article under User Permissions.

Create a New User and Grant Permissions in SQL Server 2019

The Extended Properties page allows custom properties to be added to database users.

This page displays the name of the selected database and the collation used which are read-only fields. The page also has an option to view or specify the extended properties for the object.

Create a New User

Click OK to create this user.

Create a New User using T-SQL

Syntax:
USE <database-name>
CREATE USER <user-name> FOR LOGIN <login-name> 

The following creates a new user Steve in the HR database:

SQL Script: Create New DB User
USE HR 
GO 
    CREATE USER 'Steve' FOR LOGIN 'Steve' 
GO
Want to check how much you know SQL Server?

Tidak ada komentar:

Posting Komentar