Cron command without using password to access MYSQL database

Asked

Viewed 445 times

1

Good personal day, lately I’ve been receiving warnings related to a cron I created on 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 issue since I need to access the 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

Someone would know how to do the same action without having to put the password in charge?

Thank you

1 answer

0

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

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

Then just run without the need to 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 the command reference: mysql-config-editor

  • thanks for the answer, it seems that it can solve my problem, the question now is: How to configure the access via mysql_config_editor inside cPanel?

  • you can use the mysql-config-editor to save the settings to a file, and can pass the file path with the settings to the cron using the parameter --defaults-extra-file

Browser other questions tagged

You are not signed in. Login or sign up in order to post.