1

I am on Ubuntu. I did not set any password to my root account during the MySQL installation process. I am trying to run MySQL with

mysql -u root 

However, I can't, ending up with the following access denied error.

ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)

Then, I thought it might be due to the password issue. I tried this and enter an empty password and hit the Enter key.

abc@ubuntu:~$ mysql -u root -p
Enter password: 
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)

Then, I even tried entering a password (my user password on the computer). I ended up with this

abc@ubuntu:~$ mysql -u root -p
Enter password: 
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)

I have seen some solutions, but most of them require to run MySQL first in order to resolve the issue. However, I find myself not able to do anything, stuck here.

Sibbs Gambling
  • 19,274
  • 42
  • 103
  • 174
  • 1
    This might lead you in the right direction. http://askubuntu.com/questions/118772/how-to-change-root-password-for-mysql-and-phpmyadmin – sealz Feb 24 '14 at 19:48
  • @sealz Thanks for directing me there. As a newbie in all these things, I am not sure whether my problem is related to phpmyadmin. Anyways, I tried it and got `abc@ubuntu:~$ mysql -h localhost -u root ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)` – Sibbs Gambling Feb 24 '14 at 19:50
  • Few other answers mention a config file and reconfiguration steps. I don't know enough about this to provide an in depth response. Hopefully this leads you in the right direction. Good luck! – sealz Feb 24 '14 at 19:52
  • @sealz Thanks a lot. The awkward thing is I cannot open the directory of the folder mysql. So I cannot do anything to the pid file. I am indeed the admin of the computer. So weird. – Sibbs Gambling Feb 24 '14 at 19:55
  • did you try `sudo service mysql start` ? – Waqas Feb 25 '14 at 04:17
  • or you need to reset your password because you can have issues like that lamp if you didnt set your password to anything so for that you need to follow the instruction [here](http://dev.mysql.com/doc/refman/5.0/en/resetting-permissions.html#resetting-permissions-unix) and let me know if it works or not ! – Waqas Feb 25 '14 at 04:22

2 Answers2

0

You must login from root so for this you must write sudo like:

sudo mysql -p

First give your system password

then it asking for mysql server password, in my case '123' Then you acces your database.

Zeb
  • 2,687
  • 7
  • 28
  • 36
0

Your command looks ok. It looks like you need to reset the root password Resetting MySQL root password

Community
  • 1
  • 1
Adi
  • 1,263
  • 1
  • 13
  • 24