Results 1 to 23 of 23
  1. #1
    Join Date
    Apr 2006
    Posts
    516

    disable mysqldump prompting for password

    Hi,

    I wanted to ask how do I make mysqldump command to run and make sql dump directly without prompting me for password

    on cpanel server i can do this directly
    # mysqldump database_database > /backup/backup.sql

    on direct admin server i only can do this
    # mysqldump -u root -p database_database > /backup/backup.sql
    Enter password:
    I don't want this because I'm going to run this command on cronjob!

    Thanks

  2. #2
    Join Date
    Oct 2004
    Location
    Kerala, India
    Posts
    4,750
    Use below.

    mysqldump -u root -pPASSWORD database_database > /backup/backup.sql
    David | www.cliffsupport.com
    Affordable Server Management Solutions sales AT cliffsupport DOT com
    CliffWebManager | Access WHM from iPhone and Android

  3. #3
    Join Date
    Apr 2008
    Location
    USA & Germany
    Posts
    193
    Quote Originally Posted by david510 View Post
    mysqldump -u root -pPASSWORD database_database > /backup/backup.sql
    But be carefull, password will be visible in process list.

  4. #4
    Join Date
    Oct 2004
    Location
    Kerala, India
    Posts
    4,750
    Add this code inside a file and execute this file as a cron. make sure you give 755 permission to the file.


    Code:
    #!/bin/sh
    mysqldump -u root -pPASSWORD database_database > /backup/backup.sql
    David | www.cliffsupport.com
    Affordable Server Management Solutions sales AT cliffsupport DOT com
    CliffWebManager | Access WHM from iPhone and Android

  5. #5
    Join Date
    Apr 2006
    Posts
    516
    # mysqldump -u root -pmynameisjoe hen_one > /backup/one.sql
    mysqldump: Got error: 1045: Access denied for user 'root'@'localhost' (using password: YES) when trying to connect

    is there a way to by pass the password directly just like my cpanel server?
    # mysqldump database_database > /backup/backup.sql

    the command is much shorter and easier to remember..

  6. #6
    Join Date
    Oct 2004
    Location
    Kerala, India
    Posts
    4,750
    In DA the default mysql admin user is da_admin. Use the command as follows.

    Get da_admin password:
    cat /usr/local/directadmin/conf/mysql.conf

    mysqldump -u da_admin -ppassword hen_one > /backup/one.sql
    David | www.cliffsupport.com
    Affordable Server Management Solutions sales AT cliffsupport DOT com
    CliffWebManager | Access WHM from iPhone and Android

  7. #7
    Join Date
    Apr 2006
    Posts
    516
    ok it works. gee, DA isn't that friendly for that part, there's no way I can do just like the same as cPanel?

  8. #8
    Join Date
    Jan 2006
    Location
    Athens, Greece
    Posts
    1,479
    David I would say to even chmod it to 700 and be owned by root if the cron is from root.

  9. #9
    Join Date
    Oct 2004
    Location
    Kerala, India
    Posts
    4,750
    Steve_Arm,

    Yes sure, 700 is only needed if as root.
    David | www.cliffsupport.com
    Affordable Server Management Solutions sales AT cliffsupport DOT com
    CliffWebManager | Access WHM from iPhone and Android

  10. #10
    Join Date
    Sep 2002
    Location
    Top Secret
    Posts
    11,687
    Quote Originally Posted by nice-price View Post
    But be carefull, password will be visible in process list.
    Wow, such misinformation. Try again Who output (removing db info and user info)
    67-228-4-248-rev 09:20 4.00s 0.06s 0.00s mysqldump --add-drop-table -uroot -px xxxxxx db
    ps xua output
    Code:
    4138 13.0  0.0   4676  1212 pts/6    S+   09:21   0:00 mysqldump --add-drop-table -uroot -px xxxxxx database
    I'm not seeing a single password shown in there, and I haven't for years. Mysql is smarter than that

    is there a way to by pass the password directly just like my cpanel server?
    # mysqldump database_database > /backup/backup.sql
    You bet, though THIS is a bit unsafe.
    create a file called /root/.my.cnf . In there, add the following:
    Code:
    [client]
    user="insertuserhere"
    pass="insertpasswordhere"
    You need to change the user and the password, and instantly root will try to use THOSE settings instead of requiring a mysql password every time. This is very useful, say, when you're doing backups by cron.
    WHMCS Guru - WHMCS addons, management, support and more.
    WHMCS Notifications Extended - Add slack, hipchat, SMS, pushover to WHMCS !!
    Always looking for Linux, WHMCS, Support Desk work. PM for details

  11. #11
    Join Date
    Apr 2006
    Posts
    516
    hi,

    when you mentioned the one inside /root/.my.cnf

    i have a user 'hen'

    user="hen" or "root"
    pass=is it the same root passwd inside /etc/my.cnf or what password am i dealing with?

    thanks

  12. #12
    Join Date
    Sep 2002
    Location
    Top Secret
    Posts
    11,687
    remember, you're using DA's system, so you need to use the same values in /root/.my.cnf as you used earlier.
    WHMCS Guru - WHMCS addons, management, support and more.
    WHMCS Notifications Extended - Add slack, hipchat, SMS, pushover to WHMCS !!
    Always looking for Linux, WHMCS, Support Desk work. PM for details

  13. #13
    Join Date
    Apr 2006
    Posts
    516
    sorry, but i don't quite get you. ./my.cnf is a new file

    [client]
    user=root
    pass=***** [ the same password inside /etc/my.cnf ]

    i think i did it wrong, what is the correct way to do it?

  14. #14
    Join Date
    Sep 2002
    Location
    Top Secret
    Posts
    11,687
    Nevermind

    This is exactly why forums like this shouldn't be used to pass information on. Find yourself a qualified admin.

  15. #15
    Join Date
    Oct 2004
    Location
    Kerala, India
    Posts
    4,750
    In DA .my.cnf will work out. Use da_admin as the user
    Last edited by david510; 04-17-2008 at 11:04 AM. Reason: grammar mistake
    David | www.cliffsupport.com
    Affordable Server Management Solutions sales AT cliffsupport DOT com
    CliffWebManager | Access WHM from iPhone and Android

  16. #16
    Join Date
    Apr 2006
    Posts
    516
    I believe this is a technical discussions Q&A. Not 'hire yourself an admin'.

    I'm here to learn (and I have a book beside me, and this is not inside my book - which is why i'm asking over here)

  17. #17
    Join Date
    Sep 2002
    Location
    Top Secret
    Posts
    11,687
    No,
    You want a cut and paste solution, you don't want to 'learn'.
    I gave you an incredibly good solution, you simply needed to change two values that you should have already known from previous posts.

    You wanted a 'cut and paste' solution, not to learn. That's fine, but you shouldn't expect WHT to do everything for you, you need to do the legwork yourself.
    WHMCS Guru - WHMCS addons, management, support and more.
    WHMCS Notifications Extended - Add slack, hipchat, SMS, pushover to WHMCS !!
    Always looking for Linux, WHMCS, Support Desk work. PM for details

  18. #18
    Join Date
    Apr 2006
    Posts
    516
    Quote Originally Posted by david510 View Post
    In DA .my.cnf will work out. Use da_admin as the user
    thanks david, at least that's something straight to the point.. like now i already know where to find da_admin password inside /usr/local/directadmin/conf/mysql.conf

    # cat /usr/local/directadmin/conf/mysql.conf
    Code:
    user=da_admin
    passwd=mynameisjoe
    # cat /root/.my.cnf
    Code:
    [client]
    user="da_admin"
    pass="mynameisjoe"
    # mysqldump hen_one > /backup/backup2.sql
    mysqldump: Got error: 1045: Access denied for user 'da_admin'@'localhost' (using password: YES) when trying to connect

  19. #19
    Join Date
    Oct 2004
    Location
    Kerala, India
    Posts
    4,750
    It should work in the normal case. Will need to see logs why it is not working by default.
    David | www.cliffsupport.com
    Affordable Server Management Solutions sales AT cliffsupport DOT com
    CliffWebManager | Access WHM from iPhone and Android

  20. #20
    Join Date
    Nov 2001
    Location
    Philadelphia, Pa
    Posts
    949
    # mysqldump hen_one > /backup/backup2.sql
    mysqldump: Got error: 1045: Access denied for user 'da_admin'@'localhost' (using password: YES) when trying to connect
    Well, can you connect with:
    mysql -u da_admin -pmynameisjoe hen_one
    ?

    (replacing values as necessary).

  21. #21
    Join Date
    Apr 2006
    Posts
    516
    Yes, I can. no problem with
    mysqldump -u da_admin --pmynameisjoe hen_one

    The only problem I have is if
    mysqldump hen_one

    i tailed messages, tallylog, boot.log, lastlog, failog and found nothing about it inside /var/log, which log filename should i look for?

  22. #22
    Join Date
    Oct 2004
    Location
    Kerala, India
    Posts
    4,750
    What does the following command result?

    mysqladmin processlist
    David | www.cliffsupport.com
    Affordable Server Management Solutions sales AT cliffsupport DOT com
    CliffWebManager | Access WHM from iPhone and Android

  23. #23
    Join Date
    Apr 2006
    Posts
    516
    uhm it's..
    # mysqladmin processlist
    mysqladmin: connect to server at 'localhost' failed
    error: 'Access denied for user 'da_admin'@'localhost' (using password: YES)'

Posting Permissions

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