Use MariaDB and MySQL without Password (MySQL Backup)

Posted on January 9, 2021 at 1:40 pm

On older MySQL versions you could use:

/etc/mysql/debian.cnf

To get MySQL username and password to use for backup purposes.

On newer MySQL v8+ versions you just need to run this command as root user:

mysql -u root -h localhost ...

Password is not required in this case.

This is because it uses unix_socket authentication as explained here:

https://www.percona.com/blog/2019/11/01/use-mysql-without-a-password/

To allow another Linux user to auto-connect to MySQL with full privileges:

GRANT ALL PRIVILEGES ON *.* TO 'vagrant'@'localhost' IDENTIFIED VIA unix_socket;

This works also on recent MariaDB versions.

Receive updates via email

Other Posts

Updated Posts