sqlschool.gr logo

articles

Articles of SQLschool.gr Team

You are locked out from a SQL Server instance ? - A Guide How to survive

Antonios Chatzipavlis
Monday 08 April 2013

Μετά από Σαββατοκύριακο  θέλεις η Δευτέρα να είναι μια σχετικά ήρεμη μέρα χωρίς άγχος και προβλήματα.

Εσύ βέβαια μπορεί να θέλεις όμως τον διαβολάκο τον Μέρφι τον ρώτησες;

Ας έρθουμε στο θέμα μας. Για κάποιους λόγους που δεν θα εξετάσω εδώ δεν μπορείς να μπεις σε κάποιο instance του SQL Server σαν sysadmin με συνέπεια να μην μπορείς να κάνεις την δουλειά σου σαν DBA.

Δηλαδή ΟΛΑ τα sysadmin accounts είναι locked ακόμα και ο sa (αν και μπορεί να μην είναι ενεργοποιημένος οπότε το ίδιο κάνει), δεν έχεις τους BULTIN\Administrators στον SQL Server για λόγους security, και είσαι έξω και κλαίς με μαύρο δάκρυ και δεν ξέρεις   τι κάνεις;

Απλά στέλνεις ένα email στο help του sqlschool και σου δίνει την απάντηση. Αυτό έκανε και ένας συνάδελφος που κλειδώθηκε...

Βασική προϋπόθεση είναι να έχεις ένα λογαριασμό (domain ή windows) που ένα είναι στους local admins της μηχανής που έχεις εγκατεστημένο το SQL Server instance.

Αν αυτό είναι διασφαλισμένο τότε κάτι θα γίνει ακλουθώντας τα παρακάτω βήματα:

  1. Σταματάμε τα services του SQL Server  (Database Engine & SQL Agent)
  2. Ανοίγουμε ένα cmd με Administrator rights και πάμε στο Binn directory του instance μας. Αν έχουμε την default εγκατάσταση αυτό θα είναι το C:\Program Files\Microsoft SQL Server\MSSQL********\MSSQL\Binn.
  3. Ξεκινάμε το instance μας σε signle user mode εκτελώντας την sqlservr  -m. Δεν κλείνουμε αυτό το cmd παράθυρο
  4. Ανοίγουμε ένα νέο cmd και σε αυτό εκτελούμε το SQLCMD –E.
  5. Δημιουργούμε ένα χρήστη με την CREATE LOGIN και τον βάζουμε στους sysdmin με την sp_addsrvrolemember αν είσαι πριν από SQL Server 2012 ή ALTER SERVER ROLE [sysadmin] ADD MEMBER αν είσαι σε SQL Server 2012
  6. Σταματάμε το SQL Server service που είχαμε ανοίξει σε single mode
  7. Ξεκινάμε κανονικά τον SQL Server μας και μπαίνουμε με το account που φτιάξαμε και με το οποίο είμαστε sysadmins.
  8. Κάνουμε τις απαραίτητες κινήσεις ώστε να κάνουμε unlock τα ήδη κλειδωμένα sysadmin accounts και ελέγχουμε ότι μπορούμε να κάνουμε login με αυτά.
  9. Σβήνουμε το account που δημιουργήσαμε στο βήμα 5.
  10. Η διαδικασία ολοκληρώθηκε!!

Το μυστικό στην όλη διαδικασία είναι το βήμα 4 όπου μπαίνουμε στο SQL Server σαν  sysadmin επειδή έχουμε ξεκινήσει το service σε single user mode και το account που έχουμε κάνει login είναι στους local admins της μηχανής που έχουμε εγκαταστήσει τον SQL Server.

Αν δεν πληρούνται οι παραπάνω προϋποθέσεις δε μπορείς να κάνεις τίποτα από όλα όσα γράφτηκαν παραπάνω.

Αυτά και να μην ξεχνάτε τα passwords των sysadmins εντάξει;

Καλή εβδομάδα

/*antonch*/

Antonios Chatzipavlis

Antonios Chatzipavlis

Antonios is a Data Solutions Consultant and Trainer. He has been working in IT since 1988. In his career, he has worked as senior developer, IT Manager, Solutions Architect and IT Consultant. Since 1995 he has been devoted on new technologies and software development tools, mainly by Microsoft, either by training company staff and colleagues or assisting them in design, development and implementation as a consultant or chief developer. He has focused in Databases and Data Science since 1995. He specialized in Microsoft SQL Server since version 6.0 in areas like SQL Server Internals, Database Design and Development, Business Intelligence and in 2010 he has started working with Azure Data Platform, NoSQL databases, Big Data Technologies and Machine Learning. He is an active member of many IT communities in Greece, answering colleagues' questions and writing articles in his web site. He is the owner of SQLschool.gr which is a community portal with a lot of information about Microsoft SQL Server. He has been a Microsoft Certified Trainer (MCT) since 2000. Microsoft honored him as MVP on Data Platform due to his activities in SQL Server since 2010. He holds a large number of Microsoft Certifications and Microsoft SQL Server Certifications since version 6.5.

Episode

Task Flows in Microsoft Fabric

image

More Episodes...

Tip

What's New in SQL Server 2022 - Episodes

More Tips...

Become a member

If you want to receive updates from us become a member to our community.

Connect

Explore

Learn


sqlschool.gr © 2010-2025 All rights reserved

This site uses cookies for operational and analytics purposes only. By continuing to browse this site, you agree to their use.