ERROR 1698 (28000): Access denied for user 'root'@'localhost'

error 1045 (28000): access denied for user 'root'@'localhost' (using password: yes)
#1698 - access denied for user 'root'@'localhost' phpmyadmin ubuntu
mysqli_real_connect(): (hy000/1698): access denied for user 'root'@'localhost'
mariadb access denied for user
_mysql_exceptions operationalerror 1698, access denied for user 'root'@'localhost
django.db.utils.operationalerror: (1698, "access denied for user 'root'@'localhost'")
inputs mysql error in plugin error 1698 access denied for user root localhost
ubuntu 18.04 mysql access denied for user 'root'@'localhost'

I'm setting up a new server and keep running into this problem.

When I try to login to the MySQL database with the root user, I get the error:

ERROR 1698 (28000): Access denied for user 'root'@'localhost'

It doesn't matter if I connect through the terminal(SSH), through PHPMyAdmin or a MySQL Client, e.g. Navicat. They all fail.

I looked in the mysql.user table and get the following:

+------------------+-------------------+
| user             | host              |
+------------------+-------------------+
| root             | %                 |
| root             | 127.0.0.1         |
| amavisd          | localhost         |
| debian-sys-maint | localhost         |
| iredadmin        | localhost         |
| iredapd          | localhost         |
| mysql.sys        | localhost         |
| phpmyadmin       | localhost         |
| root             | localhost         |
| roundcube        | localhost         |
| vmail            | localhost         |
| vmailadmin       | localhost         |
| amavisd          | test4.folkmann.it |
| iredadmin        | test4.folkmann.it |
| iredapd          | test4.folkmann.it |
| roundcube        | test4.folkmann.it |
| vmail            | test4.folkmann.it |
| vmailadmin       | test4.folkmann.it |
+------------------+-------------------+

As you can see, root should have access.

The Server is quite simple, as I have tried to troubleshoot this for a while now..

It's running Ubuntu 16.04.1 LTS with Apache, MySQL and PHP, so that it can host websites, and iRedMail 0.9.5-1, so that it can host mail.

Login in to the MySQL database works fine before I install iRedMail. I also tried, just installing iRedMail, but then root, also doesn't work...

If someone could tell me how I fix my MySQL login problem or how I install iRedMail, on top of an existing MySQL install. And yes I tried the Installation Tips and I can't find those variables in the config files.

Some systems like Ubuntu, mysql is using by default the UNIX auth_socket plugin.

Basically means that: db_users using it, will be "auth" by the system user credentias. You can see if your root user is set up like this by doing the following:

$ sudo mysql -u root # I had to use "sudo" since is new installation

mysql> USE mysql;
mysql> SELECT User, Host, plugin FROM mysql.user;

+------------------+-----------------------+
| User             | plugin                |
+------------------+-----------------------+
| root             | auth_socket           |
| mysql.sys        | mysql_native_password |
| debian-sys-maint | mysql_native_password |
+------------------+-----------------------+

As you can see in the query, the root user is using the auth_socket plugin

There are 2 ways to solve this:

  1. You can set the root user to use the mysql_native_password plugin
  2. You can create a new db_user with you system_user (recommended)

Option 1:

$ sudo mysql -u root # I had to use "sudo" since is new installation

mysql> USE mysql;
mysql> UPDATE user SET plugin='mysql_native_password' WHERE User='root';
mysql> FLUSH PRIVILEGES;
mysql> exit;

$ service mysql restart

Option 2: (replace YOUR_SYSTEM_USER with the username you have)

$ sudo mysql -u root # I had to use "sudo" since is new installation

mysql> USE mysql;
mysql> CREATE USER 'YOUR_SYSTEM_USER'@'localhost' IDENTIFIED BY '';
mysql> GRANT ALL PRIVILEGES ON *.* TO 'YOUR_SYSTEM_USER'@'localhost';
mysql> UPDATE user SET plugin='auth_socket' WHERE User='YOUR_SYSTEM_USER';
mysql> FLUSH PRIVILEGES;
mysql> exit;

$ service mysql restart

Remember that if you use option #2 you'll have to connect to mysql as your system username (mysql -u YOUR_SYSTEM_USER)

Note: On some systems (e.g., Debian stretch) 'auth_socket' plugin is called 'unix_socket', so the corresponding SQL command should be: UPDATE user SET plugin='unix_socket' WHERE User='YOUR_SYSTEM_USER';

Update: from @andy's comment seems that mysql 8.x.x updated/replaced the auth_socket for caching_sha2_password I don't have a system setup with mysql 8.x.x to test this, however the steps above should help you to understand the issue. Here's the reply:

One change as of MySQL 8.0.4 is that the new default authentication plugin is 'caching_sha2_password'. The new 'YOUR_SYSTEM_USER' will have this auth plugin and you can login from the bash shell now with "mysql -u YOUR_SYSTEM_USER -p" and provide the password for this user on the prompt. No need for the "UPDATE user SET plugin" step. For the 8.0.4 default auth plugin update see, https://mysqlserverteam.com/mysql-8-0-4-new-default-authentication-plugin-caching_sha2_password/

permissions, I found a solution at here link, by following this solution I have solved my problem. Short steps are: sudo mysql -u root ALTER USER  ERROR 1698 (28000): Access denied for user 'root'@'localhost' while executing mysql_secure_installation on fresh installation on ubuntu Ask Question Asked 1 year, 9 months ago

Check here:

NEW Version of MYSQL does it this way.

In the new my-sql if the password is left empty while installing then it is based on the auth_socket plugin.

The correct way is to login to my-sql with sudo privilege.

$ sudo mysql -u root -p

And then updating the password using:

$ ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'new-password';

Once this is done stop and start the mysql server.

$  sudo service mysql stop
$  sudo service mysql start

For complete details you can refer to this link.

Do comment for any doubt.

mysql (mariadb) ERROR 1698 (28000): Access denied for user 'root , You need to reset the password. so for that sudo mysql -u root use mysql; update user set plugin='' where User='root'; flush privileges; exit;. I just installed MySQL server on my Ubuntu machine. All installed ok, when it asked for my password, I simply hit 'enter' so as to leave the password blank. Now when I try to login: mysql -u root

I was having this issue on an Debian 8 VM that I was interacting with through Putty on my Windows 10 desktop.

I tried the various suggestions on here but nothing quite worked and I am running MariaDB on the Debian host. In the end I found that I couldn't start the db server in safe mode but I didn't need to and the following commands actually worked for me i.e. allowing a newly created MySql user to log into the MySql/MariaDB server:

sudo service mysql restart
sudo mysql # logs in automatically into MariaDB
use mysql;
update user set plugin='' where user='your_user_name';
flush privileges;
exit;
sudo service mysql restart # restarts the mysql service

If the above doesn't quite work for you, follow the steps outlined in zetacu's post above (zetacu) then follow my steps.

Now you should be able to use a remote terminal client and securely log into mysql using the command:

mysql -u your_user_name -p

*type in the password when prompted

ERROR 1698 (28000): Access denied for user 'root'@'localhost , I've got a similar issue, the solution: 0. login to MySQL. $ sudo mysql -u root use mysql;. 1. Change Password. UPDATE user SET  ERROR 1698 (28000): Access denied for user 'root'@'localhost' It doesn't matter if I connect through the terminal(SSH), through PHPMyAdmin or a MySQL Client, e.g. Navicat. They all fail.

I would suggest to remove the Mysql connection -

UPDATE-This is for Mysql version 5.5,if your version is different ,please change the first line accordingly

sudo apt-get purge mysql-server mysql-client mysql-common mysql-server-core-5.5 mysql-client-core-5.5
sudo rm -rf /etc/mysql /var/lib/mysql
sudo apt-get autoremove
sudo apt-get autoclean

And Install Again But this time set a root password yourself. This will save a lot of effort.

sudo apt-get update
sudo apt-get install mysql-server

How to fix ERROR 1698 (28000): Access denied for user 'root , How to fix ERROR 1698 (28000): Access denied for user 'root'@'localhost' on ubuntu 18.04 Server. July 18, 2019 July 28, 2019 Ngo Tung Bao Hung 0  kurt@kurt-ThinkPad:~$ mysql -u root ERROR 1698 (28000): Access denied for user 'root'@'localhost' I tried following the instructions on Resetting the Root Password: Unix and Unix-Like Systems ; I made the text file in my home directory, and from there tried to start the MySQL server with the --init-file option.

step 1. sudo mysql -u root -p

step 2. USE mysql;

step 3. ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'admin';

Here 'admin' is your new password, yo can change it.

step 4. exit

Thanks. You are done.

Mariadb (Ubuntu), Fix ERROR 1698 (28000): Access denied for user 'root'@'localhost' in MySQL. 1 min read. 5 months ago ddos. ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES) I am an electrical engineer who mainly plays around with power systems instead of programming. Recently, I have been following a manual to install a software suite on Ubuntu.

mysql ERROR 1698 (28000): Access denied for user 'root , MySQL ERROR 1698 (28000): Access denied for user 'root'@'localhost'. Jump to bottom. solei1 edited this page on Apr 25, 2018 · 1 revision. The reason is that  ERROR 1698 (28000): Access denied for user 'root'@'localhost' Then I realized that I can login without password if I use sudo (of-course I have to enter the sudo password): $ sudo mysql -u -p

Fix ERROR 1698 (28000): Access denied for user 'root'@'localhost , From research it seems that you can't use the root user account without 'sudo' (​admin rights) on the server. So to solve it you should set up a 

MySQL ERROR 1698 (28000): Access denied for user 'root ,

Comments
  • I followed this link and the first option worked for me: askubuntu.com/questions/763336/…
  • sudo mysql_secure_installation is easiest way to fix that
  • Option 1 worked for me. But then I also needed to run sudo gedit /etc/phpmyadmin/config.inc.php. Then I did a search for AllowNoPassword and uncommented both lines that contained it. Then I was able to login as root with no password.
  • This percona blog post helped me a bit. percona.com/blog/2016/03/16/… Sounds like this happens if you try to skip setting a password for root, which then causes the 'auth_plugin' to use the unix auth_socket, which apparently just compares users.
  • Option 2 works. I think its always best practice to create a new user and use leaving root to be there!
  • Finally, an answer that actually works !! There's a zillion answers out there saying do mysqld_safe --skip-grant-tables etc, and it's not been working.
  • Ok, how to do this, if sudo mysql -u root -p doesn't let me in?
  • This worked for me using Ubuntu 18. Thanks sooo much.
  • Worked as well on ubuntu 18.04
  • Exactly what I was looking for. Thank you :) Worked on Ubuntu 18
  • this worked like a charm, lubuntu 19.04