LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   mysqldump keeps asking mysql password (https://www.linuxquestions.org/questions/linux-newbie-8/mysqldump-keeps-asking-mysql-password-897888/)

jonaskellens 08-17-2011 12:47 PM

mysqldump keeps asking mysql password
 
Hello,

I want to take a backup of a mysql-DB in a bash-script with mysqldump, but mysqldump always asks password so automatism is not possible :
Code:

[root@server ~]# mysqldump -u root -p mypass | gzip -9 > backup_db.sql.gz
Enter password:

How come ?

anomie 08-17-2011 12:57 PM

Hi, please check the mysqldump(1) manpages:
Code:

      ·  --password[=password], -p[password]

          The password to use when connecting to the server. If you use the
          short option form (-p), you cannot have a space between the option
          and the password. If you omit the password value following the
          --password or -p option on the command line, mysqldump prompts for
          one.

You're using the short option form, so...

freevps 08-17-2011 03:48 PM

false:
# mysqldump -u root -p mypass | gzip -9 > backup_db.sql.gz
true:
# mysqldump -u root -pmypass | gzip -9 > backup_db.sql.gz

trist007 08-18-2011 01:00 AM

Classic mysql mistake. Remember -p doesn't like spaces so -ppassword. You can do the same for the rest.
Code:

mysqldump -uroot -pmypass

jonaskellens 08-18-2011 04:29 AM

Thank you !


All times are GMT -5. The time now is 08:09 PM.