[EN] Solved: Error 1698 (28000) in MySQL/MariaDB
Language: this article is available in: de
Last year I installed the database server MariaDB on a Ubuntu Server 16.04 LTS using the command
sudo apt install mariadb-server
The installation was successful but the installer didn't ask me for any root password. Every login attempt failed and this error appeared:
ERROR 1698 (28000): Access denied for user 'root'@'localhost' (using password: YES)
The solution is quite easy and already explained here. In a nutshell: MariaDB on Ubuntu Server 16.04 uses the plugin "unix_socket" for authentication. You have to authenticate using your Unix account (in other words: call the MySQL client using sudo).
Attention: the use of the following commands is at your own risk! Every computer system is different. I'm not responsible for any damage! I tested the commands on my system but I don't know your system and dependency constellation. Please contact your system administrator for further information.
If you want to use e.g. phpMyAdmin and need plain authentication, you can deactivate this behavior:
- log in to your database server using sudo mysql -u root -p
- switch to the system database: use mysql;
- deactivate the plugin: UPDATE user SET plugin='' WHERE user='root';
- set a password for the database server root account UPDATE user SET password=PASSWORD('NEWPASSWORD') WHERE user='root';
- clear the cache: flush privileges;
The plain authentication (username/password) should work from now on.