cron command without using password to access MYSQL database

1

Good morning, I've been receiving warnings related to a cron that I created in 1 site to update certain data from a mysql database table.

The error is as follows:

  

Warning: Using a password on the command line interface can be   insecure.

How do I fix this problem, since I need to access bd to update it?

mysql --user=usuario --password='senha' --database=bancodados --execute="UPDATE protocolos P INNER JOIN reclamacao R SET P.status = 'Em atraso' WHERE P.id = R.id_protocolo AND P.status='Em aberto' AND DATEDIFF(NOW(),R.data_registro) >= 20

Would anyone know how to do this same action without having to put the password in the command?

Thank you

    
asked by anonymous 02.07.2018 / 12:37

1 answer

0

You can use mysql_config_editor to configure access and avoid passing the login / password open in the command line:

mysql_config_editor set --login-path=local --host=localhost --user=usuario --password=senha

Then just run without the need to pass login / password:

mysql --execute="UPDATE protocolos P INNER JOIN reclamacao R SET P.status = 'Em atraso' WHERE P.id = R.id_protocolo AND P.status='Em aberto' AND DATEDIFF(NOW(),R.data_registro) >= 20

Here is the command reference: mysql-config-editor

    
02.07.2018 / 12:54