Neste artigo abordaremos passo-a-passo a como efetuar um reset de senha de root Mysql no CentOS 7
Stop mysql
systemctl stop mysqld
Set the mySQL environment option
systemctl set-environment MYSQLD_OPTS=”–skip-grant-tables”
Start mysql usig the options you just se
systemctl start mysqld
Login as root
mysql -u root
Update the root user password with these mysql command
[ads1]mysql> UPDATE mysql.user SET authentication_string = PASSWORD(‘MyNewPassword’) WHERE User = ‘root’ AND Host = ‘localhost’;
mysql> FLUSH PRIVILEGES;
mysql> quit
*** Edit ***
As mentioned my shokulei in the comments, for 5.7.6 and later, you should use
mysql> ALTER USER ‘root’@’localhost’ IDENTIFIED BY ‘MyNewPass’;
Or you’ll get a warning
Stop mysql
systemctl stop mysqld
Unset the mySQL envitroment option so it starts normally next tim
systemctl unset-environment MYSQLD_OPTS
Start mysql normally:
systemctl start mysqld
Try to login using your new password:
mysql -u root -p
Quer mais atigos de Mysql e Linux? Que tal um Guia de Referência de Comandos?
Comente conosco seu ponto de vista. Acompanhe também nossas outras dicas do mundo Linux . Deixe seu e-mail ao lado para receber as novidades e se você tiver outras dicas do pinguim ou áreas tecnológicas, compartilhe conosco mandando seu artigo




