开发者

mysql password is messing up my dump

ok so i need to do a mysqldump of a database and this is 开发者_StackOverflowwhat i have

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


Put -psdfas@N$pr!nT in single quotes:

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.


You need to escape the '!' in the password:-

-psdfas@N$pr\!nT


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 Security for how to do this without revealing your password.


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.cnf file in the home directory of the user running mysql or 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.cnf contains something like this:

[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:

touch ~/.my.cnf
chmod 600 /root/.my.cnf


According to the destructions instructions, the arguments should have double hyphens. (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


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.

you'll need to escape out that bang (!)


You can turn off history expansion:

set +o histexpand


Try

mysqldump -u root --password='sdfas@N$pr!nT' app_pro > /srv/DUMPFILE.SQL
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜