1

I have been working on my first project using databases using MySQL. I woke up this morning unable to login to localhost. I am able to enter root with no password and none of my databases are there. What should I do?

Cyril Graze
  • 3,881
  • 2
  • 21
  • 27
lolsharp
  • 69
  • 1
  • 11

1 Answers1

0

In theory root should have access to all your databases. If you haven't deleted them, it's possible you just lost access to them. Remember that MySQL is host-sensitive when logging in.

root@%,root@localhost, root@10.0.0.1, etc... all may be assigned different permissions.

You can try skip-grant-table in my.ini, as explained in this answer:

Regaining access to lost MySQL password for PHPMyAdmin on WAMP

With this you can reset the root password and try again.

If this does not yield effect, I would look into your SQL history and see if you haven't accidentally deleted them?

Community
  • 1
  • 1
Cyril Graze
  • 3,881
  • 2
  • 21
  • 27
  • I didint delete anything but how is it possible my passsword just stopped working – lolsharp Apr 14 '17 at 19:29
  • Ok so I checked mydata folder and they are still there which is a sigh of releif I think – lolsharp Apr 14 '17 at 19:40
  • Just need to reset your root password, and you should be able to get to them. In general, you'd want to create a new MySQL user that is specific to your application, so that you are not using `root` in production. You can do this by using: https://www.digitalocean.com/community/tutorials/how-to-create-a-new-user-and-grant-permissions-in-mysql – Cyril Graze Apr 14 '17 at 19:42
  • Once you manage to reset the root password, please accept the provided answer in the system as correct. Thanks and good luck :) – Cyril Graze Apr 14 '17 at 19:43
  • Im following the post exactly however it requests a password from me when I open mysql console but accepts no password is this normal? – lolsharp Apr 14 '17 at 19:46
  • Did you stop the Wamp MySQL service, then edited `my.ini`, and then started again? If you correctly set skip-grant-tables as explained in the article, you should have no password prompt. Perhaps you edited without restarted the MySQL service? – Cyril Graze Apr 14 '17 at 19:49
  • So I reset the password but its still not showing mydatabases that are in mydata folder – lolsharp Apr 14 '17 at 19:50
  • Are you root? check that the data directory matches your configuration. If you are root, you should be able to create a new user using create and grant as in the 2nd article. – Cyril Graze Apr 14 '17 at 19:51
  • Yes i stopped edited restarted and it doesnt work :( – lolsharp Apr 14 '17 at 19:52
  • How do i check that the data directory matches my configuration? – lolsharp Apr 14 '17 at 19:56
  • `datadir` setting in `my.ini`: http://stackoverflow.com/questions/12657081/how-to-change-mysql-database-directory-on-wamp – Cyril Graze Apr 14 '17 at 19:58
  • what happens when you try to create a new user? are you allowed to do so? can you use the GRANT permissions operation as linked above? – Cyril Graze Apr 14 '17 at 20:00
  • 1
    I changed the directory and I now seem to have access to my databases and my password is the same as before I dont know what happend and how it changed but thank you. – lolsharp Apr 14 '17 at 20:02
  • 1
    Seriously thanks alot I have like 5 projects I was working on and thought it was all gone because before I didint udnerstand where databases files were even stored – lolsharp Apr 14 '17 at 20:04