How to use a MySQL password on the command line

1119210 pts.
Tags:
MySQL
Password
PHP
I have a PHP command line that I use to version our database. Whenever development adds a new database patch, that's run this script runs. Here's the script:
system('mysql --user=xxx --password=xxx < patch.sql');
But now development is saying we're getting this error message:
Warning: Using a password on the command line interface can be insecure
So, what should we do here? Should we disable that message/warning? Thanks!

Answer Wiki

Thanks. We'll let you know when a new response is added.

If your MySQL client/server version is a 5.6.x a way to avoid the WARNING message are using the mysql_config_editor tools:

mysql_config_editor set --login-path=local --host=localhost --user=username --password

Then you can use in your shell script:

mysql --login-path=local  -e "statement"

instead of:

mysql -u username -p pass -e "statement"

Discuss This Question:  

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

Thanks! We'll email you when relevant content is added and updated.

Following

Share this item with your network: