How To Change MSSQL ‘sa’ Password On The Windows Command Line

As we know ‘sa‘ login is the default administrative user for MSSQL server. It is therefore very essential to regularly change the password for security reasons. Below is two ways approach in changing the ‘sa’ or other user’s password easily on the command line.

 

SOLUTION 1:

Execute the following commands from the Windows prompt of your server:

a) First list all the MSSQL servers near you with this command.

osql -L

b) Connect to your server found (along with others) on the list using an administrator account.

osql -S servername -E

Note: The servername consist of the ‘HOSTNAME\INSTANCE’ (example ‘ZEUS\HOSTDB’)

whereby ZEUS is the hostname and HOSTDB the instance

c) Enter the following query commands to change the ‘sa’ pasword.

sp_password NULL,’new_password’,’sa’

go

d) Quit and exit the Windows command line.

quit

exit

Try now to connect to the MSSQL server using ‘sa’ with the new password.

 

SOLUTION 2:

I have written a batch script to automate the process.

So, open up the notepad or any other editor your prefere and enter the following:

REM ========================== START ==========================

 

@echo off

SetLocal EnableDelayedExpansion

mode con:cols=78 lines=30

color 3

TITLE MSSQL PASSWORD CHANGER

:User

REM Prompt the user for the user name

cls

echo.

set User=

set /P User=”Enter the user name: ”

if not defined User goto User

:OldPasswd

REM Prompt the user for the old password

cls

echo.

set OldPasswd=

set /P OldPasswd=”Enter the old password: ”

if not defined OldPasswd goto OldPasswd

:NewPasswd

REM Prompt the user for the new password

cls

echo.

set NewPasswd=

set /P NewPasswd=”Enter the new password: ”

if not defined NewPasswd goto NewPasswd

:ChangePasswd

cls

echo.

echo Wait while the new password is been implemented…

ping -n 3 127.0.0.1 >nul

osql -U %User% -P “%OldPasswd%” -Q “sp_password NULL,%NewPasswd%,%User%

echo.

echo The passowrd for %User% has been changed.

echo Press any key to end the program!

pause>nul

echo.

echo bye ^;-^)

ping -n 3 127.0.0.1 >nul

goto :EoF

REM =========================== END =============================

Copy and save this as a batch file with the name “ChgSQLPasswd.bat” or click ChgSQLPasswd.bat to download it


Posted in MSSQL, SQL, Windows and tagged , , , , , , by with comments disabled.

How To Reset And Change Local Administrator Password On Remote Windows Systems

This tutorial will show you how to reset and change local administrator password on remote windows systems. This was tested on Windows XP and Windows 2003 server but should work on Vista/7/2008 operating systems.

STEPS:

1.) Download the official PsTools from microsoft directly or click here

2.) Extract the downloaded file to a folder called PsTools

3.) Just copy pspasswd.exe to your executable path “C:\Windows\System32”

4.) Open the prompt command line (star -> Run (type “cmd” + OK) and type in the following:

pspasswd \\{IP-Address} -u administrator -p {OldPasswd} administrator {NewPasswd}

whereby:

{OldPasswd} = Old Password

{NewPasswd} = New Password

{IP-Address} = System IP Address

Reset and Change Local Administrator Password On Remote Windows System

Typing “pspasswd” displays its usage syntax.

Usage: pspasswd [\\[computer[,computer,[,…]|Domain]|@file] [-u Username [-p Pa

ssword]]] Username [NewPassword]

     computer    Direct PsPasswd to perform the command on the remote

                 computer or computers specified. If you omit the computer

                 name PsPasswd runs the command on the local system,

                 and if you specify a wildcard (\\*), PsPasswd runs the

                 command on all computers in the current domain.

     @file       PsPasswd will change the password on the computers listed

                 in the file.

     -u          Specifies optional user name for login to remote

                 computer.

     -p          Specifies optional password for user name. If you omit this

                 you will be prompted to enter a hidden password.

     Username    Specifies name of account for password change.

     NewPassword New password. If ommitted a NULL password is applied.

Have fun 😉


Posted in Vista, Windows, Windows 7, Windows Vista, Windows XP and tagged , , , , by with comments disabled.

How To Reset The Root Password In A Linux OS

You are hired to take charge of a Linux or Unix production system and no password has been provided for whatever reason (maybe the administrator has just been fired). There are two basic methods to reset the root password:
Method 1:
—————

1. Place the first installation CD/DVD in the CD/DVD-Rom

2. Reboot the system

3. enter “linux rescue” as boot option + ENTER

4. click continue to mount the system

5. cd /mnt/sysimage/ (or chroot /mnt/sysimage/ and skip to step 9)

6. type “ls” (to show the none root environment) – optional

7. type “pwd” (to show the “present working directory” in a none root environment) – optional

8. chroot . bash -i (in order to get the root environment with “bash shell”)

9. type “pwd” (to show the “present working directory” in root environment) – optional

10. type “ls” (to show root environment) – optional

11. type “passwd”    –> to reset the root password

*) other forms of system repairs (instead of just changing root password) can be perfomed here.

12. type “exit”  —> until the system reboots

Method 2:
—————

1. Reboot

2. at the menu of the boot manager (e.g. grub), type ‘e’ for editing

3. navigate to the kernel you want to boot

4. at the right of the line, enter “init 1” or “single” and press enter

5. type ‘b’ to boot the system into the single user mode

6. type “passwd” to reset the root password

7. type “reboot” to restart the system

Check out this link below for how to recover VMware ESXi root password:

Posted in CentOS, ESX, ESXi, Linux and tagged , , , by with comments disabled.