sajad torkamani

What is mysql_config_editor?

mysql_config_editor is a handy little tool that comes pre-installed with MySQL 8.0 and helps you authenticate with MySQL using a config file instead of entering a password each time.

How to use it

Create a ~/.mylogin.cnf file containing your database credentials by running the following (change the <host> and <user> values):

host=<host> && user=<user>
mysql_config_editor set --login-path=client \
	--host=$host --user=$user --password

Enter password when prompted.

Client programs like mysql and mysqldump automatically check ~/.mylogin.cnf which means, as an example, you can use mysqldump without specifying a password each time:

mysqldump <database> > <dump_file>

Passwordless authentication becomes very useful when automating MySQL-related tasks like database back ups.

Sources

Tagged: MySQL