How to execute a MySQL command from a shell script?

前端 未结 14 1157
生来不讨喜
生来不讨喜 2020-11-28 01:28

How can I execute an SQL command through a shell script so that I can make it automated?

I want to restore data I have collected in a SQL file using a shell script.

14条回答
  •  Happy的楠姐
    2020-11-28 01:58

    mysql_config_editor set --login-path=storedPasswordKey --host=localhost --user=root --password
    

    How do I execute a command line with a secure password?? use the config editor!!!

    As of mysql 5.6.6 you can store the password in a config file and then execute cli commands like this....

    mysql --login-path=storedPasswordKey ....
    

    --login-path replaces variables... host, user AND password. excellent right!

提交回复
热议问题