To reset the root password for MySQL, follow the below steps;
1 : Log in to your account using SSH.
2 : Stop the MySQL server using the appropriate command for your Linux distribution.
Command for CentOS and Fedora, type
service mysqld stop
Command for Debian and Ubuntu, type
service mysql stop
3: Restart the MySQL server with the —skip-grant-tables option. To do this, type the following command.
mysqld_safe --skip-grant-tables &
4: Log into MySQL using the following command.
mysql
5: At the mysql> prompt, reset the password. To do this, type the following command, replacing new-password with the new root password.
UPDATE mysql.user SET Password=PASSWORD('new-password') WHERE User='root';
6: At the mysql> prompt, type the following commands.
FLUSH PRIVILEGES;
exit;
7: Stop the MySQL server using the following command. You will be prompted to enter the new MySQL root password before the MySQL server shuts down.
mysqladmin -u root -p shutdown
8: Start the MySQL server normally. To do this, type the appropriate command for your Linux distribution.
For CentOS and Fedora, type
service mysqld start
For Debian and Ubuntu, type
service mysql start
No comments:
Post a Comment