Cannot reset the MySQL root password

  • 3318429
  • 21-Feb-2007
  • 27-Apr-2012

Environment


Novell NetWare 6.5
MySQL 4.x

Situation

  • The MySQL client from NetWare's System Console cannot log in to the MySQL database. Attempted to utilize KB 10093962 (How to change the MySQL root password) but this failed.
  • There is a corrupt MySQL user's table in the MySQL database preventing any updates, modifications, or connections.

Resolution

The MySQL database needs to be reset. This is done by doing the following :
  1. Unload mysqld .
  2. Rename SYS:/mysql/data to SYS:/mysql/data.old - to prevent as much data loss as possible.
  3. Run :
    mysql_install_db
  4. Start MySQL using :
    mysqld_safe --skip-grant-tables --autoclose
  5. From the System Console, run mysql .
  6. At the MySQL prompt, type in :
    UPDATE mysql.user SET Password=PASSWORD('********') WHERE User='root';
    (ensuring that the ******** is set to the password desired for root).
  7. Flush the privileges :
    FLUSH PRIVILEGES;
  8. Unload mysqld again.
  9. Copy the database subfolders (EXCEPT for the SYS:/mysql/data/mysql folder) from the SYS:/mysql/data.old/ to the new SYS:/mysql/data/ directory.
  10. Restart MySQL :
    mysqld_safe --basedir SYS:/mysql --autoclose
  11. Log in and browse to ensure the data tables exist. This can be done using the phpMyAdmin tool or using the command from the System Console :
    mysql -u root -p
    [enter the password]
    use [database name];
    SHOW TABLES;
  12. If problems persist, remove each database folder (except the SYS:/mysql/data/mysql subfolder) and restart MySQL until the root user can log in.