How do I restore MYSQL's ROOT password
- 2020-05-06 11:44:33
- OfStack
If you forget your MYSQL root password, you can restore it by following the procedure.
1. sends kill to mysqld server with the kill command to close mysqld server(not kill -9). The ID file for the ID process is usually in the same directory as MYSQL's database.
kill `cat /mysql-data-directory/hostname.pid`
you must be an root user of UNIX or an equivalent user of the SERVER you are running to perform this operation.
2. starts mysqld with the '-- skip-grant-tables' parameter.
3. log in to mysqld server with the 'mysql -h hostname mysql' command and change the password with the grant command. You can also do this: 'mysqladmin -h hostname user password password'.
(you can also use use mysql; update user =password('yourpass') where user='root'.
4. load permission table: 'mysqladmin h hostname privileges' , or SQL command' FLUSH PRIVILEGES'. (of course, you can also restart mysqld here.)
1. sends kill to mysqld server with the kill command to close mysqld server(not kill -9). The ID file for the ID process is usually in the same directory as MYSQL's database.
kill `cat /mysql-data-directory/hostname.pid`
you must be an root user of UNIX or an equivalent user of the SERVER you are running to perform this operation.
2. starts mysqld with the '-- skip-grant-tables' parameter.
3. log in to mysqld server with the 'mysql -h hostname mysql' command and change the password with the grant command. You can also do this: 'mysqladmin -h hostname user password password'.
(you can also use use mysql; update user =password('yourpass') where user='root'.
4. load permission table: 'mysqladmin h hostname privileges' , or SQL command' FLUSH PRIVILEGES'. (of course, you can also restart mysqld here.)