Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/71.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/linux/27.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
bash脚本中的Mysql密码警告_Mysql_Linux_Bash_Unix - Fatal编程技术网

bash脚本中的Mysql密码警告

bash脚本中的Mysql密码警告,mysql,linux,bash,unix,Mysql,Linux,Bash,Unix,我目前正在通过bash运行mysql。但是,它返回错误: Using a password on the command line interface can be insecure. 实现这一目标的安全方法是什么?如果没有此警告,我如何正确调用mysql #!/bin/bash/ user=test password=test database=test mysql --user='$user' --password='$password' --database='$database' -

我目前正在通过bash运行mysql。但是,它返回错误:

Using a password on the command line interface can be insecure.
实现这一目标的安全方法是什么?如果没有此警告,我如何正确调用mysql

#!/bin/bash/
user=test
password=test
database=test

mysql --user='$user' --password='$password' --database='$database' --execute='DROP DATABASE $user; CREATE DATABASE $database;'
结果

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

不要将密码放在命令行上,而是创建一个
~/.my.cnf
文件,并将密码放在其中。该文件可以为任何命令行选项提供默认值。例如,您可以将以下内容放入其中:

[client]
database = test
user = test
password = test
然后您可以运行:

mysql --execute='DROP DATABASE $user; CREATE DATABASE $database;'

确保文件的权限受到限制,这样未经授权的用户就看不到密码。

您的命令将打开一个mysql会话,并将mysql密码作为参数传递(我在第十天看到此消息).

您在哪里使用
ffmpeg\u path
变量?我认为错误与变量的用户无关。@Barmar谢谢,我做了必要的更改。如果您使用
@Barmar,警告会消失吗?我试过了,但仍然会出现相同的错误。哦,是的,这也是一个问题。它在上面显示的脚本下面几行。