Passwordless login into MySQL from localhost

 
Written By Sanjir Habib On May-18th, 2021

This one was previously enabled by default. But to be more restrictive Fedora/CenOS turned that feature off.

On enable root login into mysql / mariadb database from localhost by anyone without a password, run this command.

$sudo mysql -e 'GRANT ALL PRIVILEGES ON *.* TO `root`@`localhost` IDENTIFIED BY "" WITH GRANT OPTION'

And then you can log into mysql by just running mysql without any parameters or password.

[habib@rdb web]$ mysql
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 98
Server version: 10.5.10-MariaDB MariaDB Server

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [(none)]> \q
Bye
[habib@rdb web]$