Change MySQl Password Using .bat

Discussion in 'MySQL' started by cancer10, Feb 26, 2009.

  1. #1
    Hi

    First of all I am sorry if I am posting in a wrong section.

    Following are the steps to change MySQL root password using command prompt

    
    1) cd C:\mysql\bin\
    2) mysql -u root -p mysql -h 127.0.0.1
    3) (when prompting for password) we enter password
    4) set password = password('new password')
    
    HTML:
    I was wondering if these steps can be done using a .bat file?

    If yes how?

    I have tried creating a .bat file with the above steps but it stucks at line when it prompts for the password. can I automate it as well?


    Thanx for your help
     
    cancer10, Feb 26, 2009 IP
  2. kmap

    kmap Well-Known Member

    Messages:
    2,215
    Likes Received:
    29
    Best Answers:
    2
    Trophy Points:
    135
    #2
    create a batch file with following lines lets say c:\mysql\abc.bat

    cd C:\mysql\bin\
    mysql -u root -h 127.0.0.1 -p newpassword

    on command prompt type
    cd\mysql
    abc.bat

    Regards

    Alex
     
    kmap, Feb 26, 2009 IP
  3. cancer10

    cancer10 Guest

    Messages:
    364
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Hi

    That directly beings me to the mysql> prompt. Does not change password at all :(

    Thanx
     
    cancer10, Feb 26, 2009 IP
  4. kmap

    kmap Well-Known Member

    Messages:
    2,215
    Likes Received:
    29
    Best Answers:
    2
    Trophy Points:
    135
    #4
    make a input.txt file with following lines

    set set password = password('new password')
    exit

    now create a batch file

    create a batch file with following lines lets say c:\mysql\abc.bat

    cd C:\mysql\bin\
    mysql -u root -h 127.0.0.1 <input.txt


    cd\mysql
    abc.bat

    Regards

    Alex
     
    kmap, Feb 26, 2009 IP