Results 1 to 11 of 11
  1. #1
    Join Date
    Jan 2007
    Posts
    360

    Where to put password in this command?

    Hey.

    I have this command that I want to put into cronjob so it runs everyday.

    But when I run this command I have to input the password manually.


    Code:
    mysqlcheck -u admin -p --auto-repair --check --optimize --databases databasename

    Is it possible to include the password of admin into that command so it runs in the cronjob without asking for password manually?

    Please let me know.

    Thanks.

  2. #2
    Join Date
    Oct 2002
    Location
    State of Disbelief
    Posts
    22,952
    Just after "-p" and leave no space.
    Code:
    -pmypassword
    Having problems, or maybe questions about WHT? Head over to the help desk!

  3. #3
    Join Date
    Jan 2007
    Posts
    360
    It does not work, still asks for password and have to type it manually.

    The password it asks for is my admin password that I use to login to Plesk panel, and not the password for the database.

    The command only works if I put my admin plesk password manually.

    I wanted this command to run in cron but how can I if I have to put password manually?

    Please help.

    Thanks.

  4. #4
    Join Date
    Mar 2010
    Location
    Germany
    Posts
    681
    Hi,

    Quote Originally Posted by awaisuk View Post
    It does not work, still asks for password and have to type it manually.

    The password it asks for is my admin password that I use to login to Plesk panel, and not the password for the database.

    The command only works if I put my admin plesk password manually.

    I wanted this command to run in cron but how can I if I have to put password manually?
    I usually do (dont got it at hand right now)
    --extra-config=/root/my.cnf

    and my.cnf has the password.

    ah, wait, i wrote it down back then
    "Using check_mk mysql plugin with a password

    But i am not sure if mysqlcheck takes this argument.
    Last edited by wartungsfenster; 06-20-2011 at 05:46 PM.
    Check out my SSD guides for Samsung, HGST (Hitachi Global Storage) and Intel!

  5. #5
    Join Date
    Jan 2007
    Posts
    360
    Thanks for your help, but I am new at this, so I dont really understand what you are trying to say....alittle more explanation or a command I can put in my cron would be very helpful.

    Thanks.

  6. #6
    Join Date
    Mar 2010
    Location
    Germany
    Posts
    681
    did you read the link?

    alternatively, the mysql documentation for command line arguments and mysqlcheck
    Check out my SSD guides for Samsung, HGST (Hitachi Global Storage) and Intel!

  7. #7
    Join Date
    Jan 2007
    Posts
    360
    So I put my pass in my.cnf and then I put this at the end of the command?

    --extra-config=/root/my.cnf

    So it looks like this:


    mysqlcheck -u admin -p --auto-repair --check --optimize --databases databasename --extra-config=/root/my.cnf

    Is it right?

  8. #8
    Join Date
    Mar 2010
    Location
    Germany
    Posts
    681
    Quote Originally Posted by awaisuk View Post
    So I put my pass in my.cnf and then I put this at the end of the command?

    --extra-config=/root/my.cnf

    So it looks like this:


    mysqlcheck -u admin -p --auto-repair --check --optimize --databases databasename --extra-config=/root/my.cnf

    Is it right?
    Yeah and the entry in /root/.my.cnf (note the dots)
    should be like this:

    [client]
    password=something



    Then try it and see if it works, as I said i'm not sure it will work with mysqlcheck.

    Next time, good admin practice would be to have a script running the commands sorted by the amount of damage they could do.
    one that does check (with extended and verbose option turned on). if that one gives OK results only, run optimize.
    but if it gave an error, then rather don't optimize, but alert you (or) auto-repair.

    I'd not mix the things into one command if I can avoid it.


    well, blabla. get it working first

    I only discovered the mysqlcheck command by random a few days ago and now a nagios check for it is being developed already.
    Check out my SSD guides for Samsung, HGST (Hitachi Global Storage) and Intel!

  9. #9
    It seems that you are using Plesk control panel.

    Try to use the command as :

    Code:
    mysqlcheck -u admin -p --auto-repair --check --optimize --databases databasename -p`cat /etc/psa/.psa.shadow'
    Thanks

  10. #10
    Join Date
    Feb 2005
    Location
    Australia
    Posts
    5,842
    Quote Originally Posted by awaisuk View Post
    So I put my pass in my.cnf and then I put this at the end of the command?

    --extra-config=/root/my.cnf

    So it looks like this:


    mysqlcheck -u admin -p --auto-repair --check --optimize --databases databasename --extra-config=/root/my.cnf

    Is it right?
    like wartungsfenster, I'm thinking use a .my.cnf (note the leading period). In which case your /root/.my.cnf should be:
    Code:
    [client]
    user=admin
    password=mysecret
    And your command is:
    Code:
    mysqlcheck --auto-repair --check --optimize --databases databasename
    (I think the other options are required not to be there - using a "-p" as a command option will always prompt for a password)
    Last edited by foobic; 06-20-2011 at 11:24 PM. Reason: note != not (& user != username)
    Chris

    "Some problems are so complex that you have to be highly intelligent and well informed just to be undecided about them." - Laurence J. Peter

  11. #11
    Join Date
    Jan 2007
    Posts
    360
    Quote Originally Posted by Kristian0911 View Post
    It seems that you are using Plesk control panel.

    Try to use the command as :

    Code:
    mysqlcheck -u admin -p --auto-repair --check --optimize --databases databasename -p`cat /etc/psa/.psa.shadow'
    Thanks
    That worked perfectly.

    Thank you all for your help.

Similar Threads

  1. How to password protect web pages, i can protect directories but can't put pages in.
    By philip2006 in forum Hosting Security and Technology
    Replies: 4
    Last Post: 03-04-2007, 09:13 AM
  2. free command-line zipping with password?
    By Wojtek in forum Hosting Security and Technology
    Replies: 6
    Last Post: 05-09-2006, 04:12 AM
  3. Password Sentry:(Stops password sharing of your members area script)
    By radhika in forum Other Offers & Requests
    Replies: 0
    Last Post: 09-06-2004, 03:24 PM
  4. Linux command/script to run a command for every file in a directory tree?
    By civ in forum Hosting Security and Technology
    Replies: 5
    Last Post: 01-25-2004, 08:48 PM
  5. a way to include password in an scp command?
    By recko11 in forum Hosting Security and Technology
    Replies: 3
    Last Post: 10-12-2003, 02:32 PM

Posting Permissions

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