sqlserver 2008 installation process and create a database to add user to add roles to assign permissions

Requirements: newly installed windows server2008 enterprise server; now needs to be installed on the server sqlserver2008

Sql server 2008r2 installation

From the Internet to find a more comprehensive.

 

1. Extract the files to a directory (this package is very powerful, is the integration of

SQL Server 2008 R2 Developer (x86, x64, ia64) official simplified Chinese version Download [Development eDonkey ed2k]: ed2k: // | file | cn_sql_server_2008_r2_developer_x86_x64_ia64_dvd_522724.iso | 4662884352 | E436F05BCB0165FDF7E5E61862AB6BE1 | /

SQL Server 2008 R2 Enterprise (x86, x64, ia64) official Simplified Chinese Enterprise Edition [Download eMule ed2k]: ed2k: // | file | cn_sql_server_2008_r2_enterprise_x86_x64_ia64_dvd_522233.iso | 4662884352 | 1DB025218B01B48C6B76D6D88630F541 | /

SQL Server 2008 R2 Standard (x86, x64, ia64) official Simplified Chinese Standard Edition [Download eMule ed2k]: ed2k: // | file | cn_sql_server_2008_r2_standard_x86_x64_ia64_dvd_522239.iso | 4662884352 | 18EB3AE3828811617488F2CE8E5B8420 | /

SQL Server 2008 R2 Web (x86, x64, ia64) official simplified Chinese version Download [WEB eDonkey ed2k]: ed2k: // | file | cn_sql_server_2008_r2_web_x86_x64_ia64_dvd_522629.iso | 4662884352 | E36682BD638B7790F3AD1AAA3D7369FC | /

 

 

2. Run setup.exe as an administrator, click OK          This hint requires .netframework and windoes installer environment. Generally even the newly installed windows machine, will be there, or is off by default.

Just check in "service" and "functional" in or proceed with the installation. Confirm With these two environments, can be determined.

3. Open the "SQL Server Installation Center" dialog box shown below, select installation options on the left, click on the right "New SQL Server stand-alone installation or add features to an existing installation" option, as shown:

4. Open the "SQL Server 2008 Setup" dialog box appears "Setup Support Rules" option, you can see, some of the checks have been passed, click the OK button, go to the next step, as shown:

Click OK

5. After clicking the OK button, you are prompted to enter the product key, the key here is that I use the Enterprise Edition of: "GYF3T-H2V88-GRPPH-HWRJP-QRTYB", click the Next button to continue the installation, as shown in shows:

6. Select the next license terms page, "I accept the license terms" option, click the Next button to continue the installation, as shown:

7. In the "Setup Support Files" page, click the Install button to continue, as shown below:
  1. FIG installation process is as follows:


  1. Then came the "Setup Support Rules" page, only conform to the rules in order to continue the installation, click the Next button to continue the installation, as shown:


 

  1. There have been set up roles page, click Next default:
  1. Feature Selection page appears, click Select All, set the shared directory, click Next:
  1. Examples of configuration interface, select the default instance, set the root directory of the instance, click Next:
  1. 出现磁盘要求界面,如通过点击下一步,如不通过请检查磁盘空间:
8出现服务器配置界面,根据具体需要进行设置,这里默认即可,点击下一步:

9.出现数据库引擎配置界面, 设置身份验证为混合模式,输入数据库管理员密码,即sa用户密码(p@ssw0rd),并且添加当前用户,点击下一步:

10.出现Analysis Services配置页面,添加当前用户,点击下一步:
  1. 出现Reporting Services配置页面,按照默认的设置,单击下一步:
  1. 出现错误和使用情况报告页面,根据自己的需要进行选择,单击下一步继续安装:
  1. 出现安装规则页面,如果全部通过,点击下一步:
  1. 出现准备安装页面,检查要安装的功能选项,点击安装:
  1. 正在安装,如下图所示:
  1. 安装完成(需要等待一段时间)点击关闭:

 

11.启动SQL SERVER 2008,选择开始菜单中的 Microsoft SQL Server R2中的配置工具,然后点击 SQL server 配置管理器:


12.最后启动微软为我们提供的集成工具,按照上图中的选择SQL Server Manager Studio选项打开,输入用户名和密码进入,如图所示:

至此sql server已经按完成。
SqlServer 添加用户 添加角色 分配权限
--创建一个简单的登录,登录名为:newlogin;登录密码:123456;默认数据库:master,默认数据库也可以不指定。
EXEC sp_addlogin 'newlogin','123456','master'
--创建用户
--创建一个简单的用户,如果不指定用户名,则添加到当前数据库登录名中,如果不指定角色,则该用户默认属于public角色。下为添加newlogin登录名。
EXEC sp_adduser 'newlogin'
--创建一个带用户名的用户,用户可以与登录名相同(同上一种类似),也可以不同,但要设定当前登录名,用户角色可选,默认为public。下为将用户newuser添加到newlogin登录名中。
EXEC sp_adduser 'newlogin','newuser'
--创建角色
EXEC sp_addrole 'newrole'
--下为将用户下为将用户newuser添加到newlogin登录名中。并指定newrole角色。
EXEC sp_adduser 'newlogin','newuser','newrole'
--为角色newrole赋予jobs表的所有权限
GRANT ALL ON jobs TO newrole
--为角色newrole赋予sales表的查、改权限
GRANT SELECT,UPDATE ON sales TO newrole
--禁止角色newrole使用employees表的插入权限
DENY INSERT ON employees TO newrole

 

另一种创建用户和赋予角色的方式
--为登录newlogin在数据库中添加安全账户newuser
EXEC sp_grantdbaccess 'newlogin','newuser' --添加newuser为角色newrole的成员 EXEC sp_addrolemember 'newrole','newuser'

 

--数据库用户、角色、登录的删除操作
--删除当前数据库用户
EXEC sp_revokedbaccess 'newuser';
--删除数据库登录
EXEC sp_droplogin 'newlogin'
--删除数据库角色
EXEC sp_droprole 'newrole'
--从数据库角色(newrole)中删除用户(newuser)
EXEC sp_droprolemember 'newrole', 'newuser'
--用SQL代码新建登录、用户
--创建带密码的mylogin登录名,MUST_CHANGE 选项需要用户首次连接服务器时更改此密码。
CREATE LOGIN mylogin WITH PASSWORD = '123456' MUST_CHANGE;
--创建映射到凭据的登录名。
--以下示例将创建mylogin登录名。此登录名将映射到mycredential凭据。
CREATE LOGIN mylogin WITH PASSWORD = '123456',
CREDENTIAL = mycredential;
--从Windows 域帐户创建登录名
--如果从Windows 域帐户映射登录名,则登录名必须用方括号([ ]) 括起来。
CREATE LOGIN [jack\xiangzhao] FROM WINDOWS;
--如果指定用户名,则不使用默认登录名作为该数据库用户
CREATE USER myuser FOR LOGIN mylogin
--以下示例将创建用户myuser拥有的数据库角色myrole
CREATE ROLE myrole AUTHORIZATION myuser;
--以下示例将创建db_role固定数据库角色拥有的数据库角色myrole
CREATE ROLE myrole AUTHORIZATION db_role
创建数据库
USE [master]
GO
/****** Object:  Database [test]    Script Date: 03/08/2019 14:45:36 ******/
CREATE DATABASE [test] ON  PRIMARY
( NAME = N'test', FILENAME = N'C:\Program Files\Microsoft SQL Server\MSSQL10_50.MSSQLSERVER\MSSQL\DATA\test.mdf' , SIZE = 3072KB , MAXSIZE = UNLIMITED, FILEGROWTH = 1024KB )
LOG ON
( NAME = N'test_log', FILENAME = N'C:\Program Files\Microsoft SQL Server\MSSQL10_50.MSSQLSERVER\MSSQL\DATA\test_log.ldf' , SIZE = 1024KB , MAXSIZE = 2048GB , FILEGROWTH = 10%)
GO
ALTER DATABASE [test] SET COMPATIBILITY_LEVEL = 100
GO
IF (1 = FULLTEXTSERVICEPROPERTY('IsFullTextInstalled'))
begin
EXEC [test].[dbo].[sp_fulltext_database] @action = 'enable'
end
GO
ALTER DATABASE [test] SET ANSI_NULL_DEFAULT OFF
GO
ALTER DATABASE [test] SET ANSI_NULLS OFF
GO
ALTER DATABASE [test] SET ANSI_PADDING OFF
GO
ALTER DATABASE [test] SET ANSI_WARNINGS OFF
GO
ALTER DATABASE [test] SET ARITHABORT OFF
GO
ALTER DATABASE [test] SET AUTO_CLOSE OFF
GO
ALTER DATABASE [test] SET AUTO_CREATE_STATISTICS ON
GO
ALTER DATABASE [test] SET AUTO_SHRINK OFF
GO
ALTER DATABASE [test] SET AUTO_UPDATE_STATISTICS ON
GO
ALTER DATABASE [test] SET CURSOR_CLOSE_ON_COMMIT OFF
GO
ALTER DATABASE [test] SET CURSOR_DEFAULT  GLOBAL
GO
ALTER DATABASE [test] SET CONCAT_NULL_YIELDS_NULL OFF
GO
ALTER DATABASE [test] SET NUMERIC_ROUNDABORT OFF
GO
ALTER DATABASE [test] SET QUOTED_IDENTIFIER OFF
GO
ALTER DATABASE [test] SET RECURSIVE_TRIGGERS OFF
GO
ALTER DATABASE [test] SET  DISABLE_BROKER
GO
ALTER DATABASE [test] SET AUTO_UPDATE_STATISTICS_ASYNC OFF
GO
ALTER DATABASE [test] SET DATE_CORRELATION_OPTIMIZATION OFF
GO
ALTER DATABASE [test] SET TRUSTWORTHY OFF
GO
ALTER DATABASE [test] SET ALLOW_SNAPSHOT_ISOLATION OFF
GO
ALTER DATABASE [test] SET PARAMETERIZATION SIMPLE
GO
ALTER DATABASE [test] SET READ_COMMITTED_SNAPSHOT OFF
GO
ALTER DATABASE [test] SET HONOR_BROKER_PRIORITY OFF
GO
ALTER DATABASE [test] SET  READ_WRITE
GO
ALTER DATABASE [test] SET RECOVERY FULL
GO
ALTER DATABASE [test] SET  MULTI_USER
GO
ALTER DATABASE [test] SET PAGE_VERIFY CHECKSUM
GO
ALTER DATABASE [test] SET DB_CHAINING OFF
GO
EXEC sys.sp_db_vardecimal_storage_format N'test', N'ON'
GO
USE [test]
GO
/****** Object:  Table [dbo].[test_tab]    Script Date: 03/08/2019 14:45:37 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[test_tab](
[name] [nchar](10) NULL,
[id] [int] NULL,
[job] [nchar](10) NULL
) ON [PRIMARY]
GO

Guess you like

Origin www.cnblogs.com/utopia68/p/12395598.html