The command:
mysql -u root -p
gives the error:
ERROR 1698 (28000): Access denied for user 'root'@'localhost'
But running sudo privileges, works:
sudo mysql -u root -p
Is it possible to get rid of the sudo requirement because it prevents me from opening the database in intellij? I tried the following as in the answer to this question Connect to local MySQL server without sudo:
sudo chmod -R 755 /var/lib/mysql/
which did not help. The above question has a different error thrown
Normally while installing MySQL/MariaDB database server on Linux, it's recommended to set a MySQL root user password to secure it, and this password is required to access the database server with root user privileges.
Only the root user needs sudo requirement to login to mysql. I resolved this by creating a new user and granting access to the required databases:
CREATE USER 'newuser'@'localhost' IDENTIFIED BY 'password'; GRANT ALL PRIVILEGES ON database_name.* TO 'newuser'@'localhost';
now newuser
can login without sudo requirement:
mysql -u newuser -p
You need to change algorithm. Following work for me,
mysql > ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY ''; mysql > FLUSH PRIVILEGES;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With