Ошибка 15151 sql server

How to fix the 15151 error on the SQL server? Bobcares, as a part of our Server Management Services offers solutions to every query that comes our way.

15151 error on the SQL server

A login is a security principal or an object that a secure system may authenticate. In order to connect to SQL Server, users must log in. You have the option of creating a login based on a Windows principal (such as a domain user or a Windows domain group) or one that is not (such as an SQL Server login).

A user is a database security principle. To connect to a database, there is a need to map logins to a database user. A login maps to several databases as distinct users, but it can only map as one user in each database. A user without a login can be generated in a partially contained database. By enabling a database’s guest user, a login that doesn’t map to a database user can access the database as the visitor user.

15151 error sql server

Logins are not the same as database users. In a separate step, we must map logins or Windows groups to database users or roles. Then we should provide users or roles permission to view database items.

Case 1

Error:

Msg 15151, Level 16, State 1, Line 2 Cannot alter the login ‘sa’, because it does not exist or you do not have permission.

Solution:

This mistake occurred due to a lack of rights. SA stands for system administrator and is the highest level of user in the system. If a user needs to change SA’s permissions, that user must have higher or comparable rights as the SA user.

Only users in the systemadmin group have the ability to change the rights of the SA user. By first adding any user to the systemadmin role and then using the same account to modify the system admin’s tool, we can fix the problem.

Case 2

Error:

Msg 15151, Cannot alter the user ‘xxxx’, because it does not exist or you do not have permission

Solution:

We need to create the user (CREATE USER [xxxx]) before we try to alter it. Missing the “create user” instruction before the alter may show the error. Login gets user entry to the server Database and the User gets user entry to a particular database. So in the script, we have to include create user from login.

[Looking for a solution to another query? We are just a click away.]

Conclusion

In this article, we have provided a general idea from our Tech team regarding the 15151 error along with a discussion on two use cases and its solution.

PREVENT YOUR SERVER FROM CRASHING!

Never again lose customers to poor server speed! Let us help you.

Our server experts will monitor & maintain your server 24/7 so that it remains lightning fast and secure.

GET STARTED

  • Remove From My Forums
  • Question

  • Hi,

       We are getting the below error when we are trying to reset the password of ‘sa’ using a Security admin user.

    Error:

    Cannot alter the login ‘sa’ because it does not exist or you do not have permission. (Microsoft SQL server, Error: 15151)

Answers

  • No. When you want to alter a different principal you need at least the same or higher permissions; and SysAdmin is already the role with the highest permissions.


    Olaf Helper

    [ Blog] [ Xing] [ MVP]

    • Marked as answer by

      Thursday, October 13, 2016 12:04 PM

  • Remove From My Forums
  • Question

  • Script level upgrade for database ‘master’ failed because upgrade step ‘SSIS_hotfix_install.sql’ encountered error 15151, state 1, severity 16. This is a serious error condition which might interfere
    with regular operation and the database will be taken offline. If the error happened during upgrade of the ‘master’ database, it will prevent the entire SQL Server instance from starting. Examine the previous errorlog entries for errors, take the appropriate
    corrective actions and re-start the database so that the script upgrade steps run to completion.


    Ron Sweatland

How to fix the 15151 error on the SQL server? Bobcares, as a part of our Server Management Services offers solutions to every query that comes our way.

15151 error on the SQL server

A login is a security principal or an object that a secure system may authenticate. In order to connect to SQL Server, users must log in. You have the option of creating a login based on a Windows principal (such as a domain user or a Windows domain group) or one that is not (such as an SQL Server login).

A user is a database security principle. To connect to a database, there is a need to map logins to a database user. A login maps to several databases as distinct users, but it can only map as one user in each database. A user without a login can be generated in a partially contained database. By enabling a database’s guest user, a login that doesn’t map to a database user can access the database as the visitor user.

15151 error sql server

Logins are not the same as database users. In a separate step, we must map logins or Windows groups to database users or roles. Then we should provide users or roles permission to view database items.

Case 1

Error:

Msg 15151, Level 16, State 1, Line 2 Cannot alter the login ‘sa’, because it does not exist or you do not have permission.

Solution:

This mistake occurred due to a lack of rights. SA stands for system administrator and is the highest level of user in the system. If a user needs to change SA’s permissions, that user must have higher or comparable rights as the SA user.

Only users in the systemadmin group have the ability to change the rights of the SA user. By first adding any user to the systemadmin role and then using the same account to modify the system admin’s tool, we can fix the problem.

Case 2

Error:

Msg 15151, Cannot alter the user ‘xxxx’, because it does not exist or you do not have permission

Solution:

We need to create the user (CREATE USER [xxxx]) before we try to alter it. Missing the “create user” instruction before the alter may show the error. Login gets user entry to the server Database and the User gets user entry to a particular database. So in the script, we have to include create user from login.

[Looking for a solution to another query? We are just a click away.]

Conclusion

In this article, we have provided a general idea from our Tech team regarding the 15151 error along with a discussion on two use cases and its solution.

PREVENT YOUR SERVER FROM CRASHING!

Never again lose customers to poor server speed! Let us help you.

Our server experts will monitor & maintain your server 24/7 so that it remains lightning fast and secure.

GET STARTED

SQL Server 2012 Developer SQL Server 2012 Enterprise SQL Server 2012 Express SQL Server 2012 Standard SQL Server 2012 Web SQL Server 2014 Standard — duplicate (do not use) SQL Server 2014 Express — duplicate (do not use) SQL Server 2014 Developer — duplicate (do not use) SQL Server 2014 Enterprise — duplicate (do not use) SQL Server 2014 Web — duplicate (do not use) SQL Server 2016 Developer — duplicate (do not use) SQL Server 2016 Enterprise — duplicate (do not use) SQL Server 2016 Enterprise Core — duplicate (do not use) SQL Server 2016 Standard — duplicate (do not use) Еще…Меньше

Проблемы

Вы создаете полнотекстовый индекс, использующий полнотекстовый каталог в Microsoft SQL Server. Если каталог очень большой, SQL Server может создать некоторые схемы и функции секционирования. Эти данные сохраняются в файловых группах. Это поведение ожидается. Однако после того как вы удалите полнотекстовый индекс и каталог, эти схемы и функции секционирования не удаляются из файловых групп. Кроме того, при попытке удалить файловые группы, содержащие схемы и функции секционирования, появляется сообщение об ошибке, подобное следующему:

Сообщение 5042, уровень 16, состояние файловой группы ‘ ‘filegroup_name‘ ‘ не может быть удалено, так как оно не пустое.

При попытке удаления схем секционирования и функций появляются сообщения об ошибках, похожие на приведенные ниже.

Сообщение 15151, уровень 16, состояние 1Cannot Drop схема секционирования «scheme_name«, так как она не существует или отсутствует разрешение. Сообщение 15151, уровень 16, состояние 1Cannot отменяет функцию секционирования «function_name«, так как она не существует или отсутствует разрешение.

Решение

Эта проблема впервые устранена в следующем накопительном обновлении SQL Server:

  • Накопительное обновление 6 для SQL Server 2014 с пакетом обновления 1 (SP1)

  • Накопительное обновление 1 для SQL Server 2016

  • Накопительное обновление 13 для SQL Server 2014

  • Накопительное обновление 10 для SQL Server 2012 с пакетом обновления 2

  • Накопительное обновление 2 для SQL Server 2012 с пакетом обновления 3 (SP3)

Примечание.Сведения о последних сборках SQL Server можно найти в разделе где найти сведения о последних сборках SQL Server.

Статус

Корпорация Майкрософт подтверждает наличие этой проблемы в своих продуктах, которые перечислены в разделе «Применяется к».

Ссылки

Ознакомьтесь с терминологией , которую корпорация Майкрософт использует для описания обновлений программного обеспечения.

Нужна дополнительная помощь?

Нужны дополнительные параметры?

Изучите преимущества подписки, просмотрите учебные курсы, узнайте, как защитить свое устройство и т. д.

В сообществах можно задавать вопросы и отвечать на них, отправлять отзывы и консультироваться с экспертами разных профилей.

  • Remove From My Forums
  • Question

  • Script level upgrade for database ‘master’ failed because upgrade step ‘SSIS_hotfix_install.sql’ encountered error 15151, state 1, severity 16. This is a serious error condition which might interfere
    with regular operation and the database will be taken offline. If the error happened during upgrade of the ‘master’ database, it will prevent the entire SQL Server instance from starting. Examine the previous errorlog entries for errors, take the appropriate
    corrective actions and re-start the database so that the script upgrade steps run to completion.


    Ron Sweatland

  • Remove From My Forums
  • Question

  • Script level upgrade for database ‘master’ failed because upgrade step ‘SSIS_hotfix_install.sql’ encountered error 15151, state 1, severity 16. This is a serious error condition which might interfere
    with regular operation and the database will be taken offline. If the error happened during upgrade of the ‘master’ database, it will prevent the entire SQL Server instance from starting. Examine the previous errorlog entries for errors, take the appropriate
    corrective actions and re-start the database so that the script upgrade steps run to completion.


    Ron Sweatland

I have the following script and I keep getting errors when it is executed.

USE [master]
GO

If Not EXISTS (Select loginname from [master].[dbo].[syslogins]
    Where name = 'xxxx' and dbname = 'xxxx-xxxx')
BEGIN
    CREATE LOGIN [xxxx] WITH PASSWORD=N'xxxxx', DEFAULT_DATABASE=[xxxx-xxxx], DEFAULT_LANGUAGE=[us_english], CHECK_EXPIRATION=OFF, CHECK_POLICY=OFF
    ALTER LOGIN [xxxx] ENABLE
END
GO

USE [xxxx-xxxx]
ALTER USER [xxxx] WITH DEFAULT_SCHEMA=[db_datareader]
ALTER ROLE [db_datareader] ADD MEMBER [xxxx]
ALTER ROLE [db_datawriter] ADD MEMBER [xxxx]
ALTER ROLE [db_owner] ADD MEMBER [xxxx]
GO

I have tried several permutations of this script with no success. It does create the login but won’t let me alter the «user» or «role» properties. When I can get it to work with no errors, it does not make the changes to the user profile.

asked Oct 2, 2019 at 23:29

Eldon Z's user avatar

3

You are missing create user before you alter it.

Login — gets you entry to the server
Database User — gets you entry to a particular database

so in your script, add create user from login ...

USE [xxxx-xxxx]
create user [xxxx] from login [xxxx] <--- this is needed !
ALTER USER [xxxx] WITH DEFAULT_SCHEMA=[db_datareader]
ALTER ROLE [db_datareader] ADD MEMBER [xxxx]
ALTER ROLE [db_datawriter] ADD MEMBER [xxxx]
ALTER ROLE [db_owner] ADD MEMBER [xxxx]
GO

few things :

  • sys.syslogins is deprecated.
  • dbatools has cmdlets for Login and user management which you can leverage for automation.

answered Oct 3, 2019 at 1:23

Kin Shah's user avatar

Kin ShahKin Shah

61.8k6 gold badges118 silver badges235 bronze badges

Few Basic ideas.

A login is a security principal, or an entity that can be authenticated by a secure system. Users need a login to connect to SQL Server. You can create a login based on a Windows principal (such as a domain user or a Windows domain group) or you can create a login that is not based on a Windows principal (such as an SQL Server login).

A user is a database level security principal. Logins must be mapped to a database user to connect to a database. A login can be mapped to different databases as different users but can only be mapped as one user in each database. In a partially contained database, a user can be created that does not have a login. For more information about contained database users, see CREATE USER (Transact-SQL). If the guest user in a database is enabled, a login that is not mapped to a database user can enter the database as the guest user.

Logins are distinct from database users. You must map logins or Windows groups to database users or roles in a separate operation. You then grant permissions to users or roles to access database objects.

As mentioned by @Dan Guzman you need to create a user in the database [xxxx-xxxx] mapped to the login xxxx you are creating. Then you can run the 2nd section of your code.
Example:

CREATE LOGIN WanidaBenshoof   
    WITH PASSWORD = '8fdKJl3$nlNv3049jsKK';  
USE AdventureWorks2012;  
CREATE USER Wanida FOR LOGIN WanidaBenshoof 

In case you are thinking of contained user.
Contained Database Users — Making Your Database Portable

Reference:

  1. Create a Login
  2. Create a Database User

answered Oct 3, 2019 at 1:30

SqlWorldWide's user avatar

SqlWorldWideSqlWorldWide

12.9k3 gold badges25 silver badges50 bronze badges

Шон Ланге помог мне с этим, он не хотел отвечать, поэтому я подумала, что отвечу, может, это кому-нибудь поможет. Исправление было объяснено здесь

Самое главное, я не делал всю шараду, эти строки были самыми важными, которые помогли:

В диспетчере конфигурации SQL Server на левой панели выберите Службы SQL Server. На правой панели найдите свой экземпляр SQL Server. (Экземпляр SQL Server по умолчанию включает в себя (MSSQLSERVER) после имени компьютера. Именованные экземпляры отображаются в верхнем регистре с тем же именем, что и на зарегистрированных серверах.) Щелкните правой кнопкой мыши экземпляр SQL Server и выберите пункт Свойства.

и этот

На вкладке Параметры запуска в поле Указать параметры запуска введите -m и нажмите кнопку Добавить. (Это тире, затем строчная буква м.)

Понравилась статья? Поделить с друзьями:
  • Ошибка 1515 гранта
  • Ошибка 1514 рхх
  • Ошибка 15517 ms sql как исправить
  • Ошибка 15094 ауди
  • Ошибка 1514 тарков