Why do I get an error message when I try to access mysql?

When I try to access mysql. I got following error message:

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

Note: Following "secure your server" guide. I created a sudo user instead of using 'root'
I have tried with the sudo user password and without one.

2 Replies

Have you created a MySQL user yet? If so, then it looks like either the password is incorrect or the MySQL user doesn't have permissions for the database you wanted to access. We have many different distro specific guides for setting up MySQL that may help.

In general, when you first log into MySQL use:

mysql -u root -p

You'll want to use the password you set up when installing MySQL.

Then, you'll want to run the following commands from the MYSQL prompt to create the database, create the user, and give it database permissions respectively:

create database testdb;
create user 'testuser'@'localhost' identified by 'password';
grant all on testdb.* to 'testuser' identified by 'password';


I installed LAMP stack using tasksel following this link: I did not install packages separately

On completion, I was able to manually confirm that Apace2, mysql and php were installed

During the install I was not asked to create a password.

Is it better to purge the tasksel install and install the packages manually?
Or is there another option?


Please enter an answer

You can mention users to notify them: @username

You can use Markdown to format your question. For more examples see the Markdown Cheatsheet.

> I’m a blockquote.

I’m a blockquote.

[I'm a link] (https://www.google.com)

I'm a link

**I am bold** I am bold

*I am italicized* I am italicized

Community Code of Conduct