MySQL: How To use mysqldump pratically

Discussion in 'MySQL' started by cancer10, Sep 25, 2008.

  1. #1
    Hi,

    I am runnning MySQL Server v 5.0 on my local machine which has Windows XP Pro SP2 installed.

    I have a database "mydb" and I am trying to make use of the mysqldump command since the past 2 days (taking help from mysql.com as well as google)

    I have gone through the tutorial http://www.devarticles.com/c/a/MySQL/Backing-Up-Your-MySQL-Databases-With-MySQLDump/

    but still unable to see how to make use of it. This is the command I am running in the MySQL Command Line.

    mysqldump --host=localhost –-user root –-password=toor mydb > sql.dump

    but getting the following error

    ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that
    corresponds to your MySQL server version for the right syntax to use near 'mysql
    dump --host=localhost --user root --password=toor mydb > sql.dump' at line 1


    Please help
     
    cancer10, Sep 25, 2008 IP
  2. Zwitterion

    Zwitterion Peon

    Messages:
    1,357
    Likes Received:
    15
    Best Answers:
    0
    Trophy Points:
    0
    #2
    do u have phpmyadmin??
     
    Zwitterion, Sep 25, 2008 IP
  3. cancer10

    cancer10 Guest

    Messages:
    364
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Yes but I want to know how to make use of mysqldump function.

    Dont wanna use phpmyadmin :)

    Thanx
     
    cancer10, Sep 25, 2008 IP
  4. chisara

    chisara Peon

    Messages:
    141
    Likes Received:
    11
    Best Answers:
    0
    Trophy Points:
    0
    #4
    mysqldump --host=localhost –-user=root –-password=toor mydb > sql.dump

    When using the long commandline options like --user or --host then the = character is used as a seperation.
    When using the short commandline options like -u -h then the space is used as a seperation character.
    You are using long commandline options but for --user you used the space as a seperation character.
     
    chisara, Sep 25, 2008 IP
  5. cancer10

    cancer10 Guest

    Messages:
    364
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    that worked like a charm.

    Is there any similar command for database restore?

    Thanx
     
    cancer10, Sep 25, 2008 IP
  6. Joseph S

    Joseph S Well-Known Member

    Messages:
    1,373
    Likes Received:
    17
    Best Answers:
    0
    Trophy Points:
    155
    #6
    mysql -uuser -ppassword database < mydatabase.sql
     
    Joseph S, Sep 25, 2008 IP
  7. cancer10

    cancer10 Guest

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

    Thats helped.

    Thanx
     
    cancer10, Sep 25, 2008 IP