Error: Access denied for user 'root'@'localhost' (using password:NO) accessing Website

Asked

Viewed 58,320 times

5

Good afternoon,

I’ve been trying to run a website through a Raspberry to access with remote access. I installed OS Pipplware, along with Lamp and phpmyadmin. I sent through Filezilla the website database and everything went perfect. The phpmyadmin appeared with errors, what prevented me the import of the database for there, but after a reconfiguration I managed to put everything to work. However, the Website still has the same error:

Access denied for user 'root'@'localhost' (using password:NO)

And while trying to solve, I noticed that in mysql, both in user

mysql -h localhost -u user -p database_name

as in root,

mysql -u localhost -u root -p database_name

Same error 1045 (28000) continues to appear: Access denied for user 'root'@'localhost' (using password:NO) Does anyone know about this mistake or know how to fix it? I appreciate all the help you offer.

  • Try restarting Mysql as mysqld_safe. Also, flush the permissions.

  • try using sudo before starting mysql

4 answers

17

1 - Install Mysql and start the service with the command below:

sudo systemctl start mysql

2 - Configure Mysql initially with the command below:

sudo mysql_secure_installation

3 - Log into Mysql with the command below:

sudo mysql -u root -p

4 - Now, type the command below by replacing the word password by the password you wish:

ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'password'; flush privileges;

Done, you should be accessing Mysql without problems.

4

Try this for mysql access denied error

/etc/init.d/mysql stop
/etc/init.d/mysql start

or

/etc/init.d/mysql restart

next stage:

sudo mysqld_safe --skip-grant-tables

If you make a mistake try this one:

sudo mkdir -p /var/run/mysqld
sudo chown mysql:mysql /var/run/mysqld
sudo mysqld_safe --skip-grant-tables

from there on:

mysql

mysql>UPDATE mysql.user SET authentication_string=PASSWORD('MyNewPass') WHERE User='root' and host='localhost';

If you want NO Pass:

mysql>UPDATE mysql.user SET authentication_string=PASSWORD('') WHERE User='root' and host='localhost';

if this error 'your password does not satisfy the Current policy Requirements root' appears, then:

mysql>uninstall plugin validate_password;

or

mysql>SET GLOBAL validate_password_policy=LOW;

Then try again:

mysql>UPDATE mysql.user SET authentication_string=PASSWORD('') WHERE User='root' and host='localhost'

Update the security staff:

mysql> flush privileges;
mysql>exit

Give a Restart on duty:

sudo mysqld_safe --skip-grant-tables
/etc/init.d/mysql restart

2

This error indicates that you are trying to access the database by the root user without entering the password....

Access denied for user 'root'@'localhost' (using password:NO)

Check your database for that user’s password and then try:

mysql -u localhost -u root -psenha database_name

the password must be "pasted" in -p

-1

Edit the access user to Mysql, in my case I changed his privileges from "%"(any bank) to "localhost", it worked.

Since your online should be the reverse I think,.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.