Results 1 to 3 of 3
  1. #1
    Join Date
    Feb 2002

    Unanswered: mysqldump problems

    Hi I am a novice Mysql user.

    I can use the mysqldump utitlity just fine on the command line to make a backup of my sql tables, but when I try to call it from a script I get a "Access denied for user: 'root@localhost' (Using password: YES)" error. What gives?

    my perl script which tries using the mysqldump utility looks like this:

    system ("mysqldump -u root -p=password -c --add-drop-table db_name > db_dump.dump");


    When I try to execute the script from the command line or from CRON, I get the access denied error.
    But if I just type the same command on the command line it works great.

    Any help would be greatly appreciated. THANKS!!

  2. #2
    Join Date
    Feb 2002
    I consider it a bad idea to write passwords on command-lines, since anyone who's logged in can see the password by `ps aux` or something similar. However, if you insist on doing it this way, the correct syntax would be `mysqldump -pPASSWORD`. Notice how there is no space between the '-p' and the actual password. You could also do '--password=PASSWORD' if you think it looks better.

    In my opinion, though, the right way of doing this would be to have a file called .my.cnf on root's home directory containing at least the following lines:


    user = root

    password = PASSWD

    and then invoke mysqldump with just a '-p'. Safer and more elegant.

  3. #3
    Join Date
    Feb 2002
    Thanks Hakon! My script works great now. I still don't know why it didn't work before; but who cares.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts