Report this

What is the reason for this report?

Setup MySQL on Ubuntu Droplet getting error ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)

Posted on December 3, 2015

Hi guys, I am very new to using a service like digitalocean (opposed to a one click setup of mediatemple or godaddy) and I am trying to setup and configure a new DB using MySQL but I keep getting the error

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

I have googled this, and searched the community for answers but cannot seem to solve this issue. Am I missing something? I have tried running it as root, and running it with sudo through another user and cannot get around it. If I offer no password it gives the same error but instead of using password: YES, it’s NO.

Thanks.



This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Installed mysql - 5.7. I Had the same issue.

Tried the below steps:

1. dpkg --get-selections | grep mysql (to get the version of mysql).

2. dpkg-reconfigure mysql-server-5.7

3. mysql -u root -p

Without -p that doesn’t prompt you to ask password. Once you are in, you can create a user with a password by following steps :

CREATE USER ‘-your_name-’@‘your-hostname’ IDENTIFIED BY ‘your-password’;

GRANT ALL PRIVILEGES ON . to ‘-your_name-’@‘your-hostname’ WITH GRANT OPTION;

Exit from the root and login from the you gave above.

mysql -u -p

For some reason still just typing mysql does not work. AT ALL. Please let me know if this works, else I have other steps.

Use the right password.

I used mysql -u root -p and enter password and got working.

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Get started for free

Sign up and get $200 in credit for your first 60 days with DigitalOcean.*

*This promotional offer applies to new accounts only.