Tag: administration

  • Start SQL Server in Single User Mode

    Another post for me that is simple and hopefully serves as an example for people trying to get blogging as #SQLNewBloggers.

    I saw someone recently ask how to reset the sa password, and myself (along with a few others) suggested starting SQL Server in single user mode as an administrator. The poster had problems and at one point I suggested using the command line, which I had used in the past. However that didn’t’ work,  and when I tried it myself, it gave me errors.

    The errors were Operating System errors, which indicated that the errorlog location wasn’t accessible by me. So I decided to elevate my privileges.

    2015-07-06 13_48_41-Start menu

    Once I did that, I was able to get the service to start:

    2015-07-06 13_52_27-Administrator_ Command Prompt - sqlservr   -m -s sql2012

    I’m not sure what was hard here, and this is how I’ve always managed to start and stop SQL Server in single user mode from the command line. I then see the output of what is sent to the error log at the console.

    However I also searched around and found a few other ways that are easy to accomplish.

    Net Start

    I haven’t often used net start for commands, but I have a few times. In this case, I looked at BOL and found I could do this:

    2015-07-06 13_43_20-Administrator_ Command Prompt

    This is essentially what clicking "start" in the services applet or Configuration Manager does. However I can add in my "m" parameter with a slash (/) instead of a dash.

    To stop the service, I use NET STOP.

    2015-07-06 13_43_44-Administrator_ Command Prompt

    Configuration Manager

    If you run Configuration Manager, you can also add parameters. First, right click the service and get the properties. Then you want the "Startup Parameters" tab. In there, you can add a parameter in the top box, as I’ve done here.

    2015-07-06 13_44_19-SQL Server (SQL2012) Properties

    Clicking "Add" will put it in the list.

    2015-07-06 13_44_26-SQL Server (SQL2012) Properties

    When you stop the service, the next startup will have this parameter take effect.

    2015-07-06 13_44_06-Sql Server Configuration Manager

    Beware that when you start things up, the first connection that successfully logs into SQL Server will be the only one allowed. Any applications looking to connect, monitoring programs (SQL Monitor or DLM Dashboard) or other clients can take your connection, so be careful and quick.

    SQLNewBlogger

    This was really a quick writeup. I stopped my service and played for 10 minutes, ran a few searches, and took some screenshots. I would have been faster, but I wanted to document this.

    This is great practice for a skill you need rarely, but when you do, you’ll be stressed. Be sure you can start and stop SQL Server a few ways, and add parameters like trace flags and the -m for emergencies.

    References

  • Using the DAC

    Another post for me that is simple and hopefully serves as an example for people trying to get blogging as #SQLNewBloggers.

    The DAC is a really important tool for anyone managing a SQL Server. You might not use it often, but when you need it, you really need it. I’d suggest you connect to your instances one a month or so using the DAC, just to be sure you know how to do it.

    The most common reason to use the DAC is when a runaway query is consuming so many resources the user can’t connect. The DAC is guaranteed resources, so you can always connect.

    When you use SQLCMD, the -A switch lets the connection method know you want to use the DAC. The DAC only allows one connection, so only one admin can connect. This also means it’s important to disconnect quickly if you don’t need the DAC.

    To connect, I use a normal set of parameters, -S for my server and -E for Windows auth. However I then add the -A, which connects me through the DAC.

    2015-07-13 10_48_04-Command Prompt

    Once I connect, I can run any of the normal commands, I need, like rebuilding master or killing a connection.

    2015-07-13 10_48_23-SQLCMD

    Keep this as a tool in your toolbox and practice regularly.

    SQLNewBlogger

    This was a quick post that follows on from starting SQL in single user mode as well as using the DAC in SSMS. I really just took some shots as I connected from SQLCMD.

    References

    The first link I saw was from my friend, Pinal Dave.

  • Password for SQL Server Service Accounts

    I wrote recently about my philosophy for service accounts, and wanted to add a few more thoughts.

    Security is important for our database servers. One of the loopholes that everyone should be aware of is that the service running SQL Server has complete control over the service and potentially if this account were compromised, the security of our installation would be at risk.

    In this post I wanted to address two things related to service account passwords. The mechanics of building and working with these passwords and the ongoing maintenance in terms of changing the passwords.

    Creating Passwords

    One of the tools I recommend for anyone administering computer systems, including my parents on their personal computers, is a password manager. There should be a way for you to create and store complex passwords that are not easily guessed. I use Password Safe, but 1Password, KeyPass, and others are just as good.

    Typically I’ve used these to store the administrative passwords for various systems for all DBAs, sysops, etc. to use. However I haven’t used these for service accounts.

    Why not?

    Mostly because I don’t think any of us should be logging in as services. Apart from initial setup and testing, we shouldn’t use service accounts for anything.

    I always recommend long, complex, random passwords for services. The password should be created and written down long enough for someone to enter it twice in the areas reserved for credentials, and then the paper should be destroyed.

    I write these down because I want extremely long (20+), random strings that aren’t memorable and are really a one-time use string. Used just long enough to enter into the Services applet or as a credential in a PoSh (or other) script.

    If you use groups for your account rights, and you should even for service accounts (SQL Server makes this easy), you can always use another account to test access. Grant it the same permissions and groups, and perform your tests.

    Changing Passwords

    I don’t worry about changing service account passwords. Yes, I know this isn’t recommended, but services rarely change or are used to log on, we can limit the access of an account to a particular machine, and since the password isn’t stored, it’s not very vulnerable to cracking.

    If you are worried, then create a new, long, random string for the particular service(s) that are suspected to be vulnerable.

    I don’t allow expiration of service account passwords, though in a few organizations that have required yearly service account password changes, we’ve scheduled the changes for slow periods, not waiting until the expiration occurred. I can almost guarantee that accounts will expire during a critical time when machines should not go down.

    One caution. I know that changing passwords to long, complex strings is hard, and that there’s a temptation to set services to the same password or use some pattern to build passwords.

    Don’t.

    Patterns are poor security, and coupling services together with the same password (or account) is not worth the risk of issues if one system requires a change or the password is disclosed.

    banner_468x60_2015_speaking

  • My SQL Server Service Account Philosophy

    Recently someone sent me a question about service accounts. They weren’t sure how they should go about setting accounts up for various instances and services in their environments. Specifically they asked me about having domain accounts, or accounts separate for services.

    Note that I’ve managed SQL Server for years this way in environments up to hundreds of instances. I haven’t managed thousands, so there might be issues with this philosophy at scale.

    Here’s how I view service accounts. In a short list, I try to manage things like this:

    • Domain accounts for the SQL database engine and SQL Agent
    • Separate accounts for all instances and all Agent services
    • Long, complex, one-time passwords that aren’t stored.

    This has worked well for me, providing separation of services so that password changes or security issues on one instance don’t affect other instances.

    It’s also been scalable in that I rarely setup SQL Server instances. In most organizations I’ve worked in, we are adding a few instances a week at the most. The overhead to create two new accounts per instance (db engine and Agent) is minimal.

    Note that I would also have a separate domain account for SSAS or other items I install.

    With today’s rapid provisioning of machines through virtualized environments, I realize this isn’t necessarily a good hard and fast rule. If I expect an instance to be a production level instance and live for some period of time in the organization, I’d follow this philosophy.

    However if I am bringing online development and test instances that may not be kept around permanently, I think the local service accounts are fine. These will probably handle your needs and are worth scripting into your VM/instance creation process.

    I’ll add a few more thoughts on this across other posts, but there’s my idea in a nutshell.