Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to recover mysql password in ubuntu 16.04

Tags:

mysql

ubuntu

Mysql version - mysql Ver 14.14 Distrib 5.7.18, for Linux (x86_64) using EditLine wrapper.

I had forgotten my password and tried many commands online.Also the problem is that grant tables command not working in my terminal.

like image 455
Koushik Andhavarapu Avatar asked May 27 '17 19:05

Koushik Andhavarapu


1 Answers

~$ cat /etc/issue
Ubuntu 16.04.3 LTS \n \l

~$ aptitude show mysql-server |grep Version
Version: 5.7.20-0ubuntu0.16.04.1

In file: /etc/mysql/debian.cnf are two important lines:

user     = debian-sys-maint
password = <unique password>

Use that user and password to login to mysql: Once logged in as debian-sys-maint you can:

FLUSH PRIVILEGES;
ALTER USER 'root'@'localhost' IDENTIFIED BY 'new_password';
like image 160
Worik Avatar answered Oct 21 '22 04:10

Worik