In this example, passwordless authentication will be configured for root. If you want to reset root password, issue the following command.
mysqladmin -u root --password=abc123
Create root's hidden .my.cnf file.
Update root's hidden .my.cnf file so that only root and read/write the file.
chmod 0600 /root/.my.cnf
Append the following to root's hidden .my.cnf file.
[client] password = abc123
You should now be able to connect ot mySQL / MariaDB as root without a password.
mysql -u root
Additionally, you will be able to issue mySQL commands on the command line with the -e option without providing root's password.
mysql -e "show databases;"