SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Guru phantom007's Avatar
    Join Date
    May 2008
    Posts
    752
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)

    Question Change MySQl Password Using .bat

    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

    HTML Code:
    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')
    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

  2. #2
    SitePoint Evangelist
    Join Date
    Aug 2007
    Posts
    566
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Code:
    mysql --help
    Will give you all the comand line switches.
    One of them is
    -p, --password[=name]
    Password to use when connecting to server. If password is
    not given it's asked from the tty.
    In my experience, you can do a
    Code:
    mysql -u root -pMySecretPass -h 127.0.0.1 mysql
    Note that -p and the password are together, this is not a typo.

  3. #3
    SitePoint Guru phantom007's Avatar
    Join Date
    May 2008
    Posts
    752
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)
    Hi

    Your experience worked!

    But now it does not consider the next line which is password change:

    set password = password('new password')

  4. #4
    SitePoint Evangelist
    Join Date
    Aug 2007
    Posts
    566
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    well, then a go on the mysql manual is your answer
    http://dev.mysql.com/doc/refman/5.0/...-password.html

  5. #5
    SitePoint Member
    Join Date
    Jun 2008
    Posts
    22
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Some time ago a friend share this with me..

    You need 2 files

    my.bat and mysql-init.txt

    the content is this:

    my.bat

    mysqld-nt.exe --defaults-file=c:\MySQL\MySQL Server 5.0\my.ini --init-file=C:\mysql-init.txt
    and

    mysql-init.txt

    SET PASSWORD FOR 'root'@'localhost' = PASSWORD('killer');
    Note: you need to stop the service, then run the bat. restart the service again. the new password should be working.


Bookmarks

Posting Permissions

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