Forgot your MySQL root password. Well, dont worry, it can be reset if you have root access to the machine.
1) Stop the MySQL process
root@hostname:~# /etc/init.d/mysql stop
2) Start MySQl in safe mode while skipping the grant table previlage
root@hostname:~# /usr/bin/mysqld_safe --skip-grant-tables &
[1] 6702
Starting mysqld daemon with databases from /var/lib/mysql
mysqld_safe[6763]: started
3) Now, login to MySQL as user root (doesnt ask for pwd)
root@hostname:~$ mysql --user=root mysql
4) Update the password via the following command:
mysql> update user set Password=PASSWORD('new-password-here') WHERE User='root';
Query OK, 2 rows affected (0.02 sec)
Rows matched: 2 Changed: 2 Warnings: 0
5) Flush previlages
mysql> flush privileges;
Query OK, 0 rows affected (0.02 sec)
mysql> exit
6) Start the MySQL process and login to confirm changes.
root@hostname:~# /etc/init.d/mysql start
Starting MySQL database server: mysqld.
No comments:
Post a Comment