bash mysql 密码弄乱了我的转储
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/4610028/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
mysql password is messing up my dump
提问by Matt Elhotiby
ok so i need to do a mysqldump of a database and this is what i have
好的,所以我需要对数据库进行 mysqldump,这就是我所拥有的
mysqldump -uroot -psdfas@N$pr!nT --databases app_pro > /srv/DUMPFILE.SQL
but i am getting this error
但我收到这个错误
-bash: !nT: event not found
seems to be having a hard time with the password...any other way to mysql dump
似乎很难使用密码...任何其他方式来 mysql 转储
回答by moinudin
Put -psdfas@N$pr!nTin single quotes:
放入-psdfas@N$pr!nT单引号:
mysqldump -uroot '-psdfas@N$pr!nT' --databases app_pro > /srv/DUMPFILE.SQL
The problem is that bash is interpreting the !. Strings in single quotes aren't interpreted.
问题是 bash 正在解释!. 不解释单引号中的字符串。
回答by Purpletoucan
You need to escape the '!' in the password:-
你需要逃避“!” 在密码中:-
-psdfas@N$pr\!nT
回答by mghicks
The answers so far dodge the point that you shouldn't put the password in the command line. See MySQL's End-User Guidelines for Password Securityfor how to do this without revealing your password.
到目前为止的答案回避了您不应该将密码放在命令行中的观点。有关如何在不泄露密码的情况下执行此操作,请参阅MySQL 的密码安全最终用户指南。
回答by Tim Kuijsten
Like others already said you should never specify a password on the command line since any other process on the machine is able to read it. A simple and effective solution for mysql is to use a .my.cnffile in the home directory of the user running mysql or mysqldump.
就像其他人已经说过的那样,您永远不应该在命令行上指定密码,因为机器上的任何其他进程都可以读取它。mysql 的一个简单有效的解决方案是使用.my.cnf运行 mysql 或 mysqldump 的用户的主目录中的文件。
First create it in a secure way:
首先以安全的方式创建它:
sudo touch /root/.my.cnf
sudo chown 0:0 /root/.my.cnf
sudo chmod 600 /root/.my.cnf
then make sure /root/.my.cnfcontains something like this:
然后确保/root/.my.cnf包含如下内容:
[mysql]
user=root
password=sdfas@N$pr!nT
[mysqldump]
user=root
password=sdfas@N$pr!nT
You can and should do this for your “normal” (non-root) mysql account as well. Then you never have to type your password again and still be secure. Just put a .my.cnf in your own home directory with your credentials in it and make sure only you are able to read and write to the file:
您也可以并且应该为您的“普通”(非根)mysql 帐户执行此操作。这样您就不必再次输入密码并且仍然安全。只需将 .my.cnf 放在您自己的主目录中,并在其中包含您的凭据,并确保只有您能够读取和写入该文件:
touch ~/.my.cnf
chmod 600 /root/.my.cnf
回答by Paused until further notice.
You can turn off history expansion:
您可以关闭历史扩展:
set +o histexpand
回答by pulsedemon
Try
尝试
mysqldump -u root --password='sdfas@N$pr!nT' app_pro > /srv/DUMPFILE.SQL
回答by JYelton
According to the destructionsinstructions, the arguments should have double hyphens. (http://dev.mysql.com/doc/refman/5.1/en/mysqldump.html)
根据销毁说明,参数应该有双连字符。( http://dev.mysql.com/doc/refman/5.1/en/mysqldump.html)
Try this:
尝试这个:
mysqldump --user=root --password=psdfas@N$pr!nT --databases app_pro > /srv/DUMPFILE.SQL
回答by FatherStorm
when you use ! in a command line, it means, find the last run command that starts with the following letters and place it here.. go to your command line and run "history" and then run some other comands, cd, ls, whatever. then go !h the last command you ran that started with the letter 'h' (in this case "history") will be executed.
当你使用!在命令行中,这意味着找到以以下字母开头的最后一个运行命令并将其放在此处.. 转到您的命令行并运行“history”,然后运行其他一些命令,cd、ls 等等。然后 go !h 您运行的最后一个以字母“h”(在本例中为“history”)开头的命令将被执行。
you'll need to escape out that bang (!)
你需要逃离那一声巨响(!)

