Skip to content

Reset MySQL root password

Reset MySQL root password

Answer:

If you have forgotten the MySQL root password, follow the steps below to reset the root password (for Ubuntu/Debian).

1. Shutdown MySQL

# /etc/init.d/mysql stop

2. Startup MySQL using command without grant tables, take the process to run in background

# /usr/bin/mysqld_safe --skip-grant-tables &

3. Login into the MySQL database

# mysql --user=root mysql

4. Reset password


mysql>update user set Password=PASSWORD('newpassword') WHERE User='root';
Query OK, 2 rows affected (0.03 sec)
Rows matched: 2  Changed: 2  Warnings: 0

mysql>flush privileges;
Query OK, 0 rows affected (0.02 sec)

5. Shutdown MySQL

Bring the MySQL server process to foreground now and kill it by Ctrl-C

# fg
[Ctrl-C]

6. Start MySQL using normal way

# /etc/init.d/mysql start

That's all.

Share and Enjoy:
  • Print
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google Bookmarks
  • Blogplay
  1. Prepare statement in MySQL
  2. How to create a new MySQL user?
  3. How to check and kill long running MySQL query
  4. Set the auto increment start value in MySQL?
  5. Create temporary table in MySQL

Post a Comment

Your email is never published nor shared. Required fields are marked *
*
*