8

I've forgotten my MySQL owner details. I need a way to find my username. My password will not be a problem. I use Ubuntu 12.04 Linux, and would prefer a command line solution.

Thank you in advance.

Ema4rl
  • 577
  • 1
  • 6
  • 17

2 Answers2

7

Well, then you have a clear way to restore it:

  1. Run your MySQL server with skipping grant tables option.
  2. Log in as root
  3. Run query

    SELECT DISTINCT user FROM mysql.user
    
  4. That's it - you have a list of users. Save it somewhere, then run server normally and try your user names one by one.

Tip: if you want to reset root password, there's a corresponding manual page.

Alma Do
  • 37,009
  • 9
  • 76
  • 105
0

Well there is simple way how to change mysql user password as root

mysql -u root -p password
mysql> SET PASSWORD FOR username = PASSWORD('new_password_here');
Kārlis Millers
  • 664
  • 2
  • 11
  • 29