Resetting or Changing the MySQL Root Password
If you're facing difficulties changing the MySQL root password and username in Ubuntu server, consider the following steps:
Stop the MySQL Service:
sudo /etc/init.d/mysql stop
Start the MySQL Configuration:
sudo mysqld --skip-grant-tables &
Connect to MySQL as Root:
mysql -u root mysql
For MySQL Versions Below 8.0:
Update the password:
UPDATE mysql.user SET Password = PASSWORD('YOURNEWPASSWORD') WHERE User = 'root';
Flush privileges:
FLUSH PRIVILEGES;
For MySQL Versions 8.0 and Above:
Flush privileges:
FLUSH PRIVILEGES;
Alter root user:
ALTER USER 'root'@'localhost' IDENTIFIED BY 'YOURNEWPASSWORD';
Flush privileges again:
FLUSH PRIVILEGES;
Cleanup:
Kill the temporary MySQL process:
sudo killall -9 mysqld
Start the normal daemon:
sudo service mysql start
Remember, this method is not considered the most secure, but it should get the job done. PhpMyAdmin will be updated automatically if it's configured to connect to the MySQL server using the updated credentials.
The above is the detailed content of How Can I Reset My MySQL Root Password in Ubuntu?. For more information, please follow other related articles on the PHP Chinese website!