mySQL / MariaDB - passwordless authentication

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.

touch /root/.my.cnf

 

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;"

 




Did you find this article helpful?

If so, consider buying me a coffee over at Buy Me A Coffee

Add a Comment




We will never share your name or email with anyone. Enter your email if you would like to be notified when we respond to your comment.





Please enter fab8f in the box below so that we can be sure you are a human.