I tried to delete and reinstall mariadb, also deleting /var/lib/mysql/ but i cant reset the root password because after a new installation with the command mysql_secure_installation I can insert the root password.
The first result on google gives you all the steps needed to reset your password. I have read it and agree with the steps described within. It’s the exact steps I would suggest myself.
So here it is:
As a sidenote, we encourage all types of questions on this forum, however I feel the need to tell you that your approach is not one that will help you grow. I notice you are working with apache and mariadb, which means you are doing some development. Knowing how to search for your answers online is a great skill to have as a developer. Improving your searching skill will help you be more productive.
now after i install with
sudo pacman -S mariadb mariadb-clients mariadb-libs
i use this command
sudo mariadb-install-db --user=mysql --basedir=/usr --datadir=/var/lib/mysql but my next step is
sudo mysql_secure_installation where i see this message:
Enter current password for root (enter for none): ERROR 2002 (HY000): Can't connect to local server through socket '/run/mysqld/mysqld.sock' (2) Enter current password for root (enter for none):
Are you trying to enter a password when asked
Enter current password for root (enter for none): ? On default installs you should just press enter when asked and not type any password.
Anyway, if simply pressing Enter will not work (for some reason the default password is not blank), I would follow the procedure in the link I have posted above. It describes the exact steps to reset the password, which is what I think you need to do here.
Also, is this a local machine that you use for development or a server facing the public? If it’s just a local database server you might not need to harden it with that
The problem arises from the fact that I followed many guides to solve the errors, but they only created confusion because if you try to reset the access data then gave me problems with the permissions in the folders, if you corrected the permissions then the program crashed due to an error in a plugin and so on.
I am a bit rusty, has been almost 20 years since that I don’t put my hands in apache and mysql. After 20 years I have not found any big changes in general but the novelty of mariadb has me a little off guard.
Now I solved because from where I left I forgot to run this command
sudo systemctl start mariadb and then with
sudo mysql_secure_installation everything worked fine.
I can recommend one:
MariaDB is a a fork of MySQL and is intended to be used as a drop-in replacement for MySQL, for most purposes it can be viewed as an alias of MySQL.
If you’re curious you can see the main differences here:
On the other hand 20 years ago MySQL was at version 3. A lot has changed since. One of the changes being that the default storage engine has become InnoDB which allows foreign keys definition and usage just like MSSQL already had for some time.