Para melhor visualização, recomendo resolução de no mínimo 1280 x 800 e navegador Mozilla Firefox


sexta-feira, 13 de novembro de 2020

MySQL - Esqueci a senha do root. Como resetar?

Por Eduardo Legatti

Olá,

Abaixo é possível verificar que a autenticação falhou pelo fato de eu ter esquecido a senha do root para conectar no MySQL.

[root@linux ~]# mysql -uroot -psenha
mysql: [Warning] Using a password on the command line interface can be insecure.
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)
 
Segue abaixo o roteiro que deverá ser seguido para que a senha do root seja resetada para uma nova senha. 
 
[root@linux ~]# systemctl stop mysqld
[root@linux ~]# systemctl set-environment MYSQLD_OPTS="--skip-grant-tables"
[root@linux ~]# systemctl start mysqld
[root@linux ~]# mysql -u root
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.7.28 MySQL Community Server (GPL)

Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> use mysql
Database changed

mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'senha';
Query OK, 0 rows affected (0.00 sec)

mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)

[root@linux ~]# systemctl stop mysqld
[root@linux ~]# systemctl unset-environment MYSQLD_OPTS
[root@linux ~]# systemctl start mysqld
[root@linux ~]# mysql -uroot -psenha
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 3
Server version: 5.7.28 MySQL Community Server (GPL)

Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.



Nenhum comentário:

Postagens populares