Stop the mysql server:
kill `cat /var/run/mysqld/mysqld.pid`
# mysqld_safe --skip-grant-tables --skip-networking &
 7855 [email protected]:~# 131114 14:35:02 mysqld_safe Logging to syslog. 131114 14:35:02 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql
Now you can connect to mysql as root without a password:
# mysql --user=root mysql
Reading table information for completion of table and column names You can turn off this feature to get a quicker startup with -A Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 1 Server version: 5.5.31-0+wheezy1 (Debian) Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. mysql>
Now, execute the following commands from mysql shell to reset password for root:
mysql> UPDATE mysql.user SET Password=PASSWORD('MyNewPass') WHERE User='root'; FLUSH PRIVILEGES;
Joel G Mathew, known in tech circles by the pseudonym Droidzone, is an opensource and programming enthusiast.
His favorite pastime is grappling with GNU compilers, discovering newer Linux secrets, writing scripts, hacking roms, and programs (nothing illegal), reading, blogging. and testing out the latest gadgets.
When away from the tech world, Dr Joel G. Mathew is a practising ENT Surgeon, busy with surgeries and clinical practise.