Here is a more secure way to reset password without skip-grant-tables
Suppose you want root to have myn3wp@ssw0rd
as the password
Step 01 : Create a script to execute when mysqld first start up
Create a file called /var/lib/mysql/init-file.sql
with these two lines
GRANT ALL PRIVILEGES ON *.* to root@localhost
IDENTIFIED BY 'myn3wp@ssw0rd' WITH GRANT OPTION;
Step 02 : Run these three(3) lines in the OS
chown mysql:mysql /var/lib/mysql/init-file.sql
service mysql restart --init-file=/var/lib/mysql/init-file.sql
rm -f /var/lib/mysql/init-file.sql
Step 03 : THERE IS NO STEP 03
. YOU ARE DONE !!!
Give it a Try !!!
CAVEAT
UPDATE 2013-06-17 07:05 EDT
OK Since mysqld for Ubuntu does not like init-file on the command, you must edit the my.cnf
. Please do these next two steps
STEP 01) Add these lines to my.cnf
under the [mysqld]
group header
[mysqld]
init-file=/var/lib/mysql/init-file.sql
STEP 02) Allow mysql to read files from /etc/mysql
sudo vim /etc/apparmor.d/usr.sbin.mysqld
Add the line:
/etc/mysql/*.sql r,
STEP 03) Restart MySQL
This should work for you. Give it a Try !!!
Well, if you have full access to the database host you don't need to delete and re-create the password file.
According to Using Operating System Authentication section in Database Administrator's Guide logging in as an OS user which is a member of dba
group on *nix or ora_dba
group on Windows and connecting to an Oracle Database instance using SQL*Plus with SYSDBA
or SYSOPER
privileges should do the trick.
$ ssh root@orcldbxe1
[root@orcldbxe1 ~]# su - oracle
[oracle@orcldbxe1 ~]$ groups
oinstall wheel dba
[oracle@orcldbxe1 ~]$ sqlplus / as sysdba
SQL*Plus: Release 11.2.0.2.0 Production on Fri Aug 22 08:22:35 2014
Copyright (c) 1982, 2011, Oracle. All rights reserved.
Connected to:
Oracle Database 11g Express Edition Release 11.2.0.2.0 - 64bit Production
SQL> select status from v$instance;
STATUS
------------
OPEN
SQL>
That's why it's called operating system authentication – you use operating system group. Simple and convenient, and no need to remember passwords. I always use it.
Once you're in, you can reset passwords and do other administrative tasks.
SQL> alter user spongebob identified by s3cr3t;
Best Answer
While not mentioned on technet, there is an argument to
mssql-conf
that works here,You'll have to pick a password, note for reasons unexplained The password must be at least 8 characters long and contain characters from three of the following four sets: Uppercase letters, Lowercase letters, Base 10 digits, and Symbols.. I suggest everyone use
MICROSOFTsucksH4RD
, as it satisfies that.Also, while you're there you may as well use
mssql-conf
to disable the spywareI'm just going to put there here so when I'm looking for SQL Server Password on Google because I can't remember it, I can find it.