download how_to_reset_a_forgotten_root_password.zip (4 kb)
If you never set a
root password for MySQL, then the server will
not require a password at all for connecting as
root. It is
recommended to always set a password for each user. See section
4.2.2 How to Make MySQL
Secure Against Crackers.
If you have set a
root password, but forgot what it was, you can
set a new password with the following procedure:
mysqldserver by sending a
kill -9) to the
mysqldserver. The pid is stored in a `.pid' file, which is normally in the MySQL database directory:
shell> kill `cat /mysql-data-directory/hostname.pid`
You must be either the Unix
root user or the same user
mysqld runs as to do this.
shell> mysqladmin -u root password 'mynewpassword'
mysqldand restart it normally, or just load the privilege tables with:
shell> mysqladmin -h hostname flush-privileges
Alternatively, you can set the new password using the
--skip-grant-tablesoption as described above.
shell> mysql -u root mysql
mysql> UPDATE user SET Password=PASSWORD('mynewpassword') -> WHERE User='root'; mysql> FLUSH PRIVILEGES;
mysqldand restart it normally.