1

EDIT: I have worked out what the problem was. When logging in using command prompt I was typing -u root; . The semicolon was the problem. Without the semicolon it works as expected.

I'm using easyphp and working my way through "Learning PHP, MySQL and Javascript" by Robin Nixon.

I'm trying to follow along with the book I tried to create a database, but it said access denied. I uninstalled easyphp and installed the latest version. Then everything worked fine and I could go along with the book. Two days later, I'm getting the access denied message again.

"Access denied for user ''@'localhost' to database 'mysql' "

I've not changed anything. I looked at PHPMyAamin (which i haven't really learned how to use yet), and it says root localhost has all privileges. I've reinsalled easyphp but it's still the same.

I've tried turning off windows firewall completely and I still have this problem. I've looked up many topics similar but I'm still struggling.

Anyone know what this could be? If not, is it possible for me to proceed not using command prompt and just using PhPMyAdmin? I've been stuck on this too long.

Isaac Bennetch
  • 11,830
  • 2
  • 32
  • 43
  • The answer to [this](http://stackoverflow.com/questions/5875831/mysql-access-denied-for-user) question may help. – Nathan Mar 28 '14 at 12:51
  • Thanks for replying. I had seen that one. I tried entering "GRANT ALL ON *.* TO '@'localhost'; But I just get access denied. –  Mar 28 '14 at 12:58
  • By the way, why is your **user** blank? The answer's syntax is `GRANT ALL ON *.* TO '` **user** `'@'localhost'` – Nathan Mar 28 '14 at 13:04
  • Do I actually type 'user' or something in place of that? I've tried adding user and I still get access denied. If it's not user then what do I put there? I haven't created any users? Sorry, i'm very new to MySql. –  Mar 28 '14 at 13:08
  • I mean you should investigate why MySQL is not seeing a username that's trying to access it. – Nathan Mar 28 '14 at 13:14
  • In the error message it says. ''@'localhost'. But should it not say 'root@localhost' ?. Is that what you mean by not seeing a username that's trying to access it? –  Mar 28 '14 at 13:16
  • Yes. Please show the code where you're trying to access the database. – Nathan Mar 28 '14 at 13:19
  • I'm just using command prompt. So I type this "C:\Program Files (x86)\EasyPHP-DevServer-14.1VC11\binaries\mysql\bin\mysql" -u root; –  Mar 28 '14 at 13:23
  • That works fine as expected. But when I try to create a database or just about do anything it says access denied. –  Mar 28 '14 at 13:23
  • It's working now. I think it was because I was adding a semicolon! In the book I'm using there is no semicolon after the -u root. Anyway thanks so much for your time and patience Nath. –  Mar 28 '14 at 13:28
  • It's nice to know it's working. You're welcome :) – Nathan Mar 28 '14 at 13:30

1 Answers1

0

Try logging in with this:

mysql -p -u root

When asked for a password, leave it blank and then press enter.

Nathan
  • 1,220
  • 3
  • 15
  • 26