Roshan Nalawade
Roshan Nalawade

Reputation: 182

ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES) on linux 16.04

I am new to MySQL and trying to start MySQL but I am getting this error. I also saw other solutions for same type of problem but still it is not working. Here I tried entering my root password on Enter password prompt.

mysql -u root -p

Enter password: 

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

Upvotes: 0

Views: 1279

Answers (3)

Roshan Nalawade
Roshan Nalawade

Reputation: 182

Now my problem is solved i followed these things:

Stopped the MySQL service
sudo /etc/init.d/mysql stop

Start MySQL without a password
sudo mysqld_safe --skip-grant-tables &

I got this error
2017-06-20T18:50:06.475664Z mysqld_safe Directory '/var/run/mysqld' for UNIX socket file don't exists.

used these commands to fix it:
mkdir -p /var/run/mysqld chown mysql:mysql /var/run/mysqld

then followed these commands:

sudo mysqld_safe --skip-grant-tables &
mysql -uroot
use mysql;
update user set password=PASSWORD("mynewpassword") where User='root';
flush privileges;
quit

And it started working.

Upvotes: 0

Alex Dupuis
Alex Dupuis

Reputation: 366

I don't have access to MySQL at the moment but, if I remember correctly, if you don't have a password (which not a good idea), you simply don't use the -p.

Upvotes: 0

rainerhahnekamp
rainerhahnekamp

Reputation: 1136

As far as I know the message using password: NO only appears if you simply press Enter instead of typing in the password.

Upvotes: 1

Related Questions