Zapp
Zapp

Reputation: 232

mysql error 1045 (28000) no root password

I have no root password. I am only working locally and learning. I logged out to learn to try and backup a database, and now I have problems with logging in.

mysql -u root -p;

Now that gives me this error:

Warning: Using password on the command line interface can be insecure. Error 1045 (28000) access denied for user 'root'@'localhost' (using password: YES)

So I try this:

mysql -u root;

It logs me in with no errors, but I cant see the databases I created because I'm not root even though I'm using 'root' in the command. I know I have no password because PHP logs in without one.

Upvotes: 0

Views: 1006

Answers (1)

Hitesh Mundra
Hitesh Mundra

Reputation: 1588

when you put mysql -uroot -p; command then your password is ; for root@localhost user is incorrect, thats why its showing error. when you log in mysql -u root or simply mysql then it log into mysql prompt with anonymous user which is created by default when you installed mysql.

So you should run the command

mysql -uroot -p

then enter the password. if your password is not set or nothing then press enter.

Upvotes: 2

Related Questions