MYSQL error: 1045 (28000): access denied for user 'root' @ 'localhost'

When I try to connect to sql server and type the following at a command prompt:

shell> mysql --user=username--password=password db_name 

I get an error:

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

What does this error mean?

+4
source share
2 answers

This means that your password is incorrect or the root account does not have access to the database on the localhost host.

Look at the right side panel. There are several questions equivalent to yours.

-1
source

There seems to be no space between username and --password


If you don’t know the root password with Debian or Ubuntu, there is an easy way to reset: First, get the exact version of your server using

 sudo dpkg --get-selections | grep 'mysql-server-' 

Then just use sudo dpkg-reconfigure mysql-server-5.x

(btw, replace 5.x with your real version number)


With a new installation, the root password is empty by default, so it should be able to log in using only

 mysql -u root 

After installation, add the root password after installation

 mysqladmin -u root password [newpassword] 

In most cases, before working with the database, you should also configure dedicated accounts with limited rights.

+1
source

All Articles