hi,
I was trying to setup Mariadb initial config with the command
sudo mariadb-secure-installation
to my surprise I got an error from the get go saying:
mariadb-secure-installation
NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB
SERVERS IN PRODUCTION USE! PLEASE READ EACH STEP CAREFULLY!
In order to log into MariaDB to secure it, we'll need the current
password for the root user. If you've just installed MariaDB, and
haven't set the root password yet, you should just press enter here.
Enter current password for root (enter for none):
ERROR 1698 (28000): Access denied for user 'root'@'localhost'
Enter current password for root (enter for none):
ERROR 1698 (28000): Access denied for user 'root'@'localhost'
Enter current password for root (enter for none):
I have tried everything from starting the server with and loggin in with --skip-grant-tables
Nothing works.
Those anyone else have the same problem ?
Do you understand that what MariaDB calls the "root user " is NOT the root user of your Linux system? It is the user that can manage the internal database(s) of MariaDB. MariaDB has it’s own set of users.
I’m installing ,programming and using MySQL databases (and others) and them MariaDB for the last 25 years … yeah … I think I know the difference between Linux root user (Linux UID 0) and the Database admin user (root) user.
my error is the same when doing :
mysql -u root -p
mysql: Deprecated program name. It will be removed in a future release, use '/usr/bin/mariadb' instead
Enter password:
ERROR 1698 (28000): Access denied for user 'root'@'localhost'
Also Mariadb version is
mariadb --version
mariadb from 11.8.6-MariaDB, client 15.2 for Linux (x86_64) using EditLine wrapper
btw, the database was installed fresh so there was nothing inside and I did not even had set the root passwd … the error is the first thing when using the setup software mentioned.
I wonder if the problem is that you are using sudo rather than su. Sudo grants admin privileges to a user whereas, if you use su, the user becomes root.
I always run mariadb-secure-installation from within su.
After I have done this, I quit and, while still within su, login again with
mariadb
and then enter
alter user root@localhost identified via mysql_native_password using password (“**********”);
This allows me to access MariaDB root from any user without having to use su.
I wonder if the problem is that you are using sudo rather than su
That was it!
Quite frankly I expected the exact same result using either! Quite frankly I could almost certainly claim that I’ve done this before using simply sudo rather then becoming root. But it’s ok, it simply works now.
For some reason this time it did not work.
I changed to root with su and all went well. The entire setup went as expected and the results were exactly the same as before … clearing anonymous users, using local socket, deleting test databases, db root password. … the usual MySQL/MariaDB setup safety operations.
I thought that the setup was simply sending SQL and setup operation on Mariadb … apparently changing Mariadb to operate with local sockets may require full root account.
I could swear I’ve done this before with sudo tho … in any case it is what it is.
In any case it is solved.
Blockquote and then enter
alter user root@localhost identified via mysql_native_password using password (“**********”);
This allows me to access MariaDB root from any user without having to use su.
After the mariadb-secure-installation usually there is no need to setup the db root password with the cli direct query tool.
Once the db root password is set it can be used by any other user or application.
Of course that is something to avoid at all cost. Since the DB root user should only be used for Database important operations since it has grant permission over all databases on that installation. Every single other Database should have their own user access different from the db root user.
Just as a final note I was restarting the database and migrating local development databases and noticed the initial issue was the problem with akonadi. I needed the previous version of Mariadb so i downgraded and the re-upgraded. This led to some downgrade and upgrade cycles for the Mariadb.
Those were done inside Myrlin not on cli … hence the sudo issue on the konsole I had opened at the time.
But Today I tested the issue with sudo … seemed to me like something did not make sense, sudo should have worked … and I finally found out What the issue was …
For all those facing the same problem … when the error is Access Denied be advised one can have a connection to the socket issue … try and check to see if the database server process is Actually Running … you see once we install/uninstall or downgrade the Default install does not start automatically the process on systemd … hence the error 1698 Access denied to root is misleading … it is actually a connection error.
(I know … knewb mistake)
Agreed in principle. However, I have always had two users, one linked to my personal email address for personal matters and one linked to my business email address for business. So I find it more convenient to have a root password and it means that the databases cannot be accessed for important operations by just using the local socket.