forgot password - MySQL

NOTE: you should *always* have a password for any mysql user -- espcially for root. Why? hackers know that mysql installs without a password for root. They love to get in that way.

To recover root password for mysql

  1. As unix root, stop the mysql daemon if it is running. This might be different on different systems. It may be: # /etc/init.d/mysql.server stop
    or
    # /etc/init.d/mysqld stop
    or
    # service mysqld stop
  2. Start mysql in safe mode, with the options to not read the grant tables (which have all the mysql database passwords); and also to disable networking:
    # safe_mysqld -user=mysql -skip-grant-tables -skip-networking
  3. Use the mysqladmin command to reset the password:
    # mysqladmin -u root flush-privileges password "newpassword"
  4. Restart the mysql daemon:
    # service mysqld start
  5. You can now log in to mysql with your new root password:
    # mysql -u root -p
  6. Then if needed you can reset any other passwords.

Know more

General info:
www.tibetangeeks.com
Tech info for Tibetans