how to break mysql password in ubuntu 16

Опубликовано: 19 Октябрь 2024
на канале: Vacnic IT Solution
171
5

How can I reset my MySQL password?


This is a bit gnarly. If you have a better method of updating the password without triggering a warning about PASSWORD being deprecated, I'm all ears.

Stop MySQL
sudo service mysql stop
Make MySQL service directory.
sudo mkdir /var/run/mysqld
Give MySQL user permission to write to the service directory.
sudo chown mysql: /var/run/mysqld
Start MySQL manually, without permission checks or networking.
sudo mysqld_safe --skip-grant-tables --skip-networking &
Log in without a password.
mysql -uroot mysql

Update the password for the root user.

UPDATE mysql.user SET authentication_string=PASSWORD('YOURNEWPASSWORD'), plugin='mysql_native_password' WHERE User='root' AND Host='%';
EXIT;

Turn off MySQL.
sudo mysqladmin -S /var/run/mysqld/mysqld.sock shutdown
Start the MySQL service normally.
sudo service mysql start



start the mysql client process using this command

mysql -u root

from the mysql prompt execute this command to be able to change any password

FLUSH PRIVILEGES;

Then reset/update your password

SET PASSWORD FOR root@'localhost' = PASSWORD('password');

If you have a mysql root account that can connect from everywhere, you should also do:

UPDATE mysql.user SET Password=PASSWORD('newpwd') WHERE User='root';

Alternate Method:

USE mysql
UPDATE user SET Password = PASSWORD('newpwd')
WHERE Host = 'localhost' AND User = 'root';

And if you have a root account that can access from everywhere:

USE mysql
UPDATE user SET Password = PASSWORD('newpwd')
WHERE Host = '%' AND User = 'root';

For either method, once have received a message indicating a successful query (one or more rows affected), flush privileges:

FLUSH PRIVILEGES;

Amitechnology
https://vacnic.com
  / vacnicitsolution  
   / vacnicitsolution  
  / vacnics  
  / vacnicitsolution  
  / vacnicitsolution  
https://www.tumblr.com/blog/vacnicits...
  / 585890232759687161  
  / vacnicitsolution  
https://vacnic.wordpress.com/
https://myspace.com/vacnicitsolution
https://disqus.com/by/vacnicpvtltd/
  / vacnicsocia